dotnet / dotnet/command-line-api
Invoke a parent command without specifying its subcommands
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
In my use case, both the following invocations are expected.
```
$ myprog --load checkpoint.json
$ myprog process --file test.json
```
where the root command `myprog` with the subcommand `process` can be called without specifying a subcommand. Is this use-case currently supported in `System.CommandLine`?
Using a code similar to the following, I get `Required command was not provided` error when making the first invocation above.
```csharp
using System.CommandLine;
var loadOpt = new Option("--load");
var rootCmd = new RootCommand() { loadOpt };
var fileOpt = new Option("--file");
var subCmd = new Command(name: "process") { fileOpt };
rootCmd.AddCommand(subCmd);
```
Contributor guide
Assessment
This issue has not been assessed yet.