Repository navigation
Replies: 2 comments
|
I can see your confusion. The terms stem from System.CommandLine where an "argument" is value accepted from the command line and an "option" is special argument prefixed the System.CommandLine re-uses these concepts and terms from UNIX/Linux. What may be more confusing is that the argument name isn't used on the command line (i.e. it's not a fixed name). Your example: .AddCommand()
.WithArgument<int>("--loops", "Number of loops to perform")
.WithOption<int>("--delay", "Delay in milliseconds")Would actually be called like this:
The "--loops" is used only in the generated help text and you wouldn't include the "--" the name. You'd normally do something like this (following System.CommandLine conventions): .AddCommand()
.WithArgument<int>("loops", "Number of loops to perform")
.WithOption<int>("--delay", "Delay in milliseconds")"--loops" isn't used on the command line at all. Which would produce the following help output (if you passed only |
|
Thank you for clarifying. The fact that the Argument name is not used on the command line, does that make the arguments positional, i.e. they are read in that sequence? So would be called as |
Uh oh!
There was an error while loading. Please reload this page.
I feel that the difference between
WithArgumentandWithOptionis a bit unclear as I cannot completely see the difference between them.Both take a generic type TParam which indicates that they both support a value being added after, i.e. leading to the name way to add them on command line.
So this
would end up to be specified in command line as
Very little difference ;-)
But if the purpose of
WithOptionis to make a switch like parameter, then there would IMO be no need for a TParam generic type, because it would automatically resolve to abooland result in something being turned on (or off).Like this
would end up on command line as
and result in a slower operation than
All reactions