Closed
Description
Invoking the following program with no arguments:
using System.CommandLine;
using System.CommandLine.Builder;
using System.CommandLine.Parsing;
internal static class Program
{
//private static Task<int> Main(string[] args) =>
// new CommandLineBuilder(CreateRootCommand())
// .Build()
// .InvokeAsync(args);
private static Task<int> Main(string[] args) =>
CreateRootCommand().InvokeAsync(args);
private static Command CreateRootCommand()
{
var rootCommand = new RootCommand("Specifying a sub-command is required.");
var fooCommand = new Command("foo");
rootCommand.Add(fooCommand);
return rootCommand;
}
}
results in a red error message that says "Required command was not provided." followed by the program help text, and the program returns an error exit code.
However, if I replace the Main
method above with the commented-out Main
method and invoke the program with no arguments, then nothing appears and the program returns a successful exit code.
Is this discrepancy intentional? If so, how do I make the CommandLineBuilder
version behave the same as the non-CommandLineBuilder
version?
This is using System.CommandLine 2.0.0-beta4.22272.1
Thanks!
Metadata
Metadata
Assignees
Labels
No labels