gsscoder / commandline

Terse syntax C# command line parser for .NET with F# support
1.63k stars 293 forks source link

Default value? #100

Open ekkis opened 11 years ago

ekkis commented 11 years ago

I've defined an option like this:

[Option('s', HelpText = "Save name", DefaultValue="Main")] public string SaveName { get; set; }

but when I run my programme as:

c:> test ./file-to-munch.txt -s

I get a failure of ParseArgumentsStrict. what have I done wrong?

nemec commented 11 years ago

I forget CommandLine's behavior, but what happens if you put the -s before the positional argument? (also, you have defined another option to consume ./file-to-munch.txt, right?)

ekkis commented 11 years ago

but I would imagine that

c:> test -s ./file-to-munch.txt

would cause the -s parameter to gobble the filename as an argument, which is not what's intended... which brings up the question, in unix one can use -- to end the options field, so that would allow me to write:

c:> test -s -- ./file-to-munch.txt

and that would mean: 1) specify a -s with the default value, and 2) pass an unbound parameter with value ./file-to-munch.txt

is there support for that syntax here?

nemec commented 11 years ago

It does. Or at least it should. I haven't tried it out.