Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Generate good help text instead of stack trace on unrecognized c…
…ommand (#592) So now it looks like this: ``` (base) PS E:\Git\github.com\stevefan1999-personal\dotnet-operator-sdk\src> dotnet run --project KubeOps.Play --framework net7.0 -- generator abcd Building... Specify --help for a list of available options and commands. Unrecognized command or argument 'abcd' Usage: KubeOps.Play generator [command] [options] Options: -f|--format <FORMAT> Determines the output format for the generator. Allowed values are: Yaml, Json. -o|--out <OUTPUT_PATH> The "root" path for the generator to put files in - if empty, prints to console. -?|-h|--help Show help information. Commands: crd Generates the needed CRD for kubernetes. docker Generates the docker file for building. installer Generates kustomization yaml for the whole installation of the operator. operator Generates the needed yamls to run the operator. rbac Generates the needed rbac roles for the operator. Run 'generator [command] -?|-h|--help' for more information about a command. ``` Instead of this: ``` (base) PS E:\Git\github.com\stevefan1999-personal\dotnet-operator-sdk\src> dotnet run --project KubeOps.Play --framework net7.0 -- generator abcd Building... E:\Git\github.com\stevefan1999-personal\dotnet-operator-sdk\src\KubeOps\Operator\HostExtensions.cs(33,13): warning SA1515: Single-line comment should be preceded by blank line (https://github.com/DotNetAnalyzers/StyleCopAnalyzers/blob/master/documentation/SA1515.md) [E:\Git\github .com\stevefan1999-personal\dotnet-operator-sdk\src\KubeOps\KubeOps.csproj::TargetFramework=net7.0] Specify --help for a list of available options and commands. Unhandled exception. McMaster.Extensions.CommandLineUtils.UnrecognizedCommandParsingException: Unrecognized command or argument 'abcd' at McMaster.Extensions.CommandLineUtils.CommandLineProcessor.ProcessUnexpectedArg(String argTypeName, String argValue) at McMaster.Extensions.CommandLineUtils.CommandLineProcessor.ProcessCommandOrParameter(CommandOrParameterArgument arg) at McMaster.Extensions.CommandLineUtils.CommandLineProcessor.ProcessNext() at McMaster.Extensions.CommandLineUtils.CommandLineProcessor.Process() at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Parse(String[] args) at McMaster.Extensions.CommandLineUtils.CommandLineApplication.ExecuteAsync(String[] args, CancellationToken cancellationToken) at KubeOps.Operator.HostExtensions.RunOperatorAsync(IHost host, String[] args) in E:\Git\github.com\stevefan1999-personal\dotnet-operator-sdk\src\KubeOps\Operator\HostExtensions.cs:line 28 at Program.<Main>$(String[] args) in E:\Git\github.com\stevefan1999-personal\dotnet-operator-sdk\src\KubeOps.Play\Program.cs:line 10 at Program.<Main>(String[] args) ``` The `Specify --help for a list of available options and commands` stuff is unfortunately non-removable. https://github.com/natemcmaster/CommandLineUtils/blob/81199c7ec68367ea9612be55719dc1fe08f658da/src/CommandLineUtils/Internal/CommandLineProcessor.cs#L323 --------- Co-authored-by: Christoph Bühler <[email protected]>
- Loading branch information