Skip to content

How does dashdash work in 2.x? #422

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

Closed
RedX2501 opened this issue Mar 25, 2019 · 4 comments
Closed

How does dashdash work in 2.x? #422

RedX2501 opened this issue Mar 25, 2019 · 4 comments

Comments

@RedX2501
Copy link

i want to have a command line as:

exe -g -- filename1 filename2

So I tried

 exe -g -- filename1
class Opts a
  [Option('g')]
  bool Generate {get; set;}
  [Value(0)]
  string Filename {get; set;}
}

var p = new Parser(settings => settings.EnableDashDash = true);
p.ParseArguments<Opts>(args);

I get the error:

ERROR(S):
Error setting value to option 'unknownarguments': Property set method not
found.

So what's the correct way of doing this in 2.x?

@moh-hassan
Copy link
Collaborator

To use double dash, you define options with longName, like

       [Option('g',"generate")]
         bool Generate {get; set;}

Then, to use

         exe    --generate  filename

No space between -- and the option

Filename is a free option without singlee /or double dash.
For more details, read the Wiki

@RedX2501
Copy link
Author

Is DashDash not an option to enable the end of options delimiter? Or does command line always do that?

[Option('g')]
bool someFlag

[Value(0)]
string filename

Usage

exe -g -- -g

then -g is on and filename will also contain -g preventing it from being recognized as the option -g.

See https://www.in-ulm.de/~mascheck/bourne/set-.html

@moh-hassan
Copy link
Collaborator

Is DashDash not an option to enable the end of options delimiter?

DashDash enable the end of options delimiter in the custom Parser as you did.
I wasn't thinking that you mean using DashDash as an end of option :D

See this answer by @nemec with example

I test your example with minor modification, and it's working with DashDash support

These are working

            -g -- -g 
	-g -- filename1
	-g -- -filename1

Try it online

@RedX2501
Copy link
Author

I thought it was broke due to #156

I tried

exe -g -- expected unexpected

and got no error.

Since dashdash is working I can close this.

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

No branches or pull requests

2 participants