You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
usingSystem.CommandLine;usingSystem.CommandLine.Builder;usingSystem.CommandLine.Parsing;internalstaticclassProgram{//private static Task<int> Main(string[] args) =>// new CommandLineBuilder(CreateRootCommand())// .Build()// .InvokeAsync(args);privatestaticTask<int>Main(string[]args)=>CreateRootCommand().InvokeAsync(args);privatestaticCommandCreateRootCommand(){varrootCommand=newRootCommand("Specifying a sub-command is required.");varfooCommand=newCommand("foo");rootCommand.Add(fooCommand);returnrootCommand;}}
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
Activity
KalleOlaviNiemitalo commentedon Jan 24, 2023
Before Build(), call CommandLineBuilderExtensions.UseDefaults or just CommandLineBuilderExtensions.UseParseErrorReporting.