Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Values for parameters which start with "-", give problems as they are parsed as parameters first. #44

Closed
ghuls opened this issue Nov 15, 2021 · 3 comments · Fixed by #45

Comments

@ghuls
Copy link
Contributor

ghuls commented Nov 15, 2021

Values for parameters which start with "-", give problems as they are parsed as parameters first.

❯  printf '1- 2\n3- 4\n'
1- 2
3- 4

❯  printf '1- 2\n3- 4\n' | hck -f 2 -d '- '
error: Found argument '- ' which wasn't expected, or isn't valid in this context

USAGE:
    hck --delimiter <delimiter> --fields <fields>

For more information try --help

❯  printf '1- 2\n3- 4\n' | hck -f 2 -d -- '- '
[2021-11-15T09:40:14Z ERROR hck] No such file or directory (os error 2)

❯  printf '1- 2\n3- 4\n' | hck -f 2 -d '\- '
2
4

# Try to print first 2 columns:
❯  printf '1- 2- 5\n3- 4- 9\n' | hck -f '-2' -d '\- '
error: Found argument '-2' which wasn't expected, or isn't valid in this context

USAGE:
    hck --fields <fields>

For more information try --help

❯  printf '1- 2- 5\n3- 4- 9\n' | hck -f '\-2' -d '\- '
[2021-11-15T09:50:00Z ERROR hck] Failed to parse field: \-2

@ghuls ghuls changed the title Delimiter option which starts wtih "-" is not accepted by default. Values for parameters which start with "-", give problems as they are parsed as parameters first. Nov 15, 2021
@ghuls
Copy link
Contributor Author

ghuls commented Nov 15, 2021

I guess, this needs to be added for the relevant arguments: https://docs.rs/structopt/0.2.15/structopt/clap/struct.Arg.html#method.allow_hyphen_values

ghuls added a commit to ghuls/hck that referenced this issue Nov 15, 2021
Allow arguments of options to start with a hyphen.
Fixes: sstadick#44
sstadick pushed a commit that referenced this issue Nov 15, 2021
Allow arguments of options to start with a hyphen.
Fixes: #44
@ghuls
Copy link
Contributor Author

ghuls commented Nov 16, 2021

Thanks for merging.

The changelog entry is not correct:

+## v0.6.7
+
+- [Bugfiz](https://github.com/sstadick/hck/issues/44) to allow for `-` character as separators.

Bugfix vs Bugfiz.
The patch fixes also more than just the separators option. -e, -f options can now also start with a dash: e.g. -5,7.

Something like this would be better IMHO:

Bugfix: allow arguments of options to start with a "-".

@sstadick
Copy link
Owner

Yep, you're totally right. Changelog updated as well as releases page

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants