dotnet / dotnet/command-line-api
Support for multiple commands and options not bound to a command
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
I have a scenario where a console application has a number of general options (for things like input and output files) and then a number of commands representing a pipeline of operations that it should perform, with each command having its own specific options. For example:
`myapp --i infile --o outfile command1 -a "foo" -b 42 command2 -c "bar" -d 99 command3 -e "zzz" -f false`
etc.
In building a test application it appears that:
1. If the application finds a command on the command-line then the options not associated with the command (--i and --o in the fictitious example above) are ignored - i.e. the root command handler is not called.
2. If multiple commands are specified on the command-line then only the handler for the first command is called.
3. Only if no commands are specified is the root command handler invoked, allowing me to access the value of the --i and --o options.
My questions:
1. Since I'm new to using this package - do my findings above reflect the way that System.CommandLine is intended to work?
2. Is there a way to do what I want to achieve using System.CommandLine? (Without trying to force it beyond its design assumptions)
3. If there are multiple way to do this, are there any pointers to documentation that helps me understand the trade-offs for each approach?
Thanks.
Contributor guide
Assessment
This issue has not been assessed yet.