dotnet / dotnet/command-line-api
Feature request: allow setting exit code on custom validation error
Open
Area-API
enhancement
- Dominant language
- C#
- Stars
- 3.7k
- Forks
- 428
- PR merge metrics
- No merged PRs in 30d
Description
In the process of upgrading a project to System.CommandLine v2, I'd like to move more validation up front but return exit codes specific to the validation error. For example, in a project in a command handler, they check if a string is a valid absolute URI and return a specific exit code if not. I can return the same message, but System.CommandLine just returns 1 for any argument validation errors. It would be nice if we could optionally return an exit code - perhaps by providing the context that's passed to middleware, for example.
Contributor guide
Assessment
This issue has not been assessed yet.