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

flag values that start with a hyphen are interpreted as short options and cause option parse errors. #269

Open
adrian-thurston opened this issue Sep 14, 2021 · 0 comments
Labels
bug Something isn't working

Comments

@adrian-thurston
Copy link

It's not possible to use long option arguments starting with -, when the long option is in the form --opt arg. The command line parsing library attempts to interpret the argument as a short option. For example:

+ ./bin/linux/influx query --host http://thurston05:8086/ --org monitor --token -3PpF_ISBadt4tS7e0BaKte1zDxryDwwb86cTQnUPmwau2UWe18rhCmMAHyJB-OZRZpfMp-3eYfEXQV_Au6I2A== 'from( bucket: "apps" ) |> range( start: 2021-09-14T19:03:20.021849485Z )'
Incorrect Usage: flag provided but not defined: -3PpF_ISBadt4tS7e0BaKte1zDxryDwwb86cTQnUPmwau2UWe18rhCmMAHyJB-OZRZpfMp-3eYfEXQV_Au6I2A

Removing the - from the token and adding it to the org causes a different error, likely the same root cause:

+ ./bin/linux/influx query --host http://thurston05:8086/ --org -monitor --token 3PpF_ISBadt4tS7e0BaKte1zDxryDwwb86cTQnUPmwau2UWe18rhCmMAHyJB-OZRZpfMp-3eYfEXQV_Au6I2A== 'from( bucket: "apps" ) |> range( start: 2021-09-14T19:03:20.021849485Z )'
Error: at most 1 query string can be specified as an argument, got 3

And finally, no leading - in any long option argument, option parsing succeeds:

+ ./bin/linux/influx query --host http://thurston05:8086/ --org monitor --token 3PpF_ISBadt4tS7e0BaKte1zDxryDwwb86cTQnUPmwau2UWe18rhCmMAHyJB-OZRZpfMp-3eYfEXQV_Au6I2A== 'from( bucket: "apps" ) |> range( start: 2021-09-14T19:03:20.021849485Z )'
Error: failed to execute query: 401 Unauthorized: unauthorized access

@danxmoran found this PR that attempted to fix it, but it was closed as stale due to edge cases.

urfave/cli#1135

As a workaround, the option can be specified as --opt=arg.

@danxmoran danxmoran added the bug Something isn't working label Nov 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants