dotnet / dotnet/command-line-api

Feature request: allow setting exit code on custom validation error

Open
#1,239 1 comment 1 reaction 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.