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
When an option is marked Required and a DefaultValueFactory is set, calling Option.GetRequiredValue still throws.
Program code:
usingSystem.CommandLine;varrootCommand=newRootCommand("This is the description"){newOption<string>("--required"){Required=true,DefaultValueFactory= _ =>"hello"}};varparseResult=rootCommand.Parse("-h");Console.WriteLine(parseResult.GetRequiredValue<string>("--required"));
Exception:
Unhandled exception. System.InvalidOperationException: --required is required but was not provided. at System.CommandLine.Parsing.SymbolResult.GetRequiredValue[T](String name) at System.CommandLine.ParseResult.GetRequiredValue[T](String name) at Program.<Main>$(String[] args) in C:\temp\command-name-issue\Program.cs:line 14