jpdillingham / Utility.CommandLine.Arguments

A C# .NET class library containing tools for parsing the command line arguments of console applications.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Subcommad support

RajaSrinivasan opened this issue · comments

Very crisp package. Thanks.

Wondering if there is a straight forward way to support subcommands as in:

git clone
git pull
git push

I tried to use the Operand feature but it appears that:

myprog begin start end -f 3.4

does not recognize "begin" as an operand.

However changing the usage to:

myprog -f 3.4 begin start end

does recognize begin as an operand.

Thanks for reporting this, it is likely a bug. I'll take a look.

Finally got around to looking at this, and I tried your input in the examples/Example app:

$ dotnet run
At the prompt, enter text as if it were a string of command line arguments. Enter 'exit' to exit.
> myprog begin start end -f 3.4

Argument        Value
-------         -------
f               3.4

Property        Value
-------         -------
String
Bool            False
Int             0
Double          3.4

Operands
-------
0.      myprog
1.      begin
2.      start
3.      end
>

I added another example, Echo to just pit out the result of Arguments.Parse() and it sees the leading operands as well. Under .NET Core the fully qualified path to the executable is included, but that's a known quirk.

I'm closing this for now since I wasn't able to reproduce it, but feel free to reopen it if you can.