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

What is the correct way to parse an argument with value - #574

Closed
tevoinea opened this issue Jan 31, 2020 · 4 comments
Closed

What is the correct way to parse an argument with value - #574

tevoinea opened this issue Jan 31, 2020 · 4 comments

Comments

@tevoinea
Copy link

I have a program that I would like to execute like so:

./myprogram --someArg 2 --thisFails - --anotherArg 3

Where the value of thisFails should be set to -

I've also tried: "-" to no avail

The error I'm getting is:

ERROR(S):
  Option 'thisFails' has no value.
@moh-hassan
Copy link
Collaborator

moh-hassan commented Feb 1, 2020

Use triple quote to quote "-" in the commandline, , then it will passed to the parser with Single Quote:

--somearg 2 --thisfails """-""" --anotherarg 3

@tevoinea
Copy link
Author

tevoinea commented Feb 5, 2020

In my testing, the triple quote returned a value of "-" not - but that's ok, we can work around that.

Thanks!

@tevoinea tevoinea closed this as completed Feb 5, 2020
@moh-hassan
Copy link
Collaborator

To avoid tripple quote, merging options with single dash as a value is allowed:

./myprogram --someArg 2 --thisSuccess=- --anotherArg 3  #merge longname with dash using '=' e.g `--thisSuccess=-`
./myprogram --someArg 2   -s- --anotherArg 3  #merge shortname with dash: `-s-`

@moh-hassan moh-hassan reopened this Jul 24, 2020
@moh-hassan
Copy link
Collaborator

Single dash will be considered as a value in the next release

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

No branches or pull requests

2 participants