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
Is your feature request related to a problem? Please describe.
I would like to have a way to specify expected exit codes to be documented in the --help output, so that users know what codes to expect.
Describe the solution you'd like
I suggest a method on the ICommandConfigurator interface like so for documenting exit codes:
add.AddCommand<CreateFileCommand>("create").WithDescription(CreateFileDescription).WithExitCode(0,"The file is created successfully").WithExitCode(1,"The file could not be created because it failed validation").WithExitCode(2,"Network error").WithExitCode(3,"Server error")
Describe alternatives you've considered
I currently add a block of text to my descriptions like so:
privateconststringCreateFileDescription=""" Creates a new file [yellow]EXIT CODES:[/] 0 The file is created successfully 1 The file could not be created because it failed validation 2 Network error 3 Server error """;
However, the proposed solution above would mean the exit codes wouldn't need to appear between the description and the usages. I'd suggest the exit codes should appear last, after the options - but I'm open to thoughts. It also means that the formatting would be more standardised.
Additional context
Let me know if this is something you'd be open to receiving a PR for!
Thanks
Please upvote 👍 this issue if you are interested in it.
The text was updated successfully, but these errors were encountered:
Well now, isn't this an interesting idea @tobysmith568
Out of interest, do you know of other CLI applications that do this? I'm interested if this is a 'standard' thing eg. POSIX, GNU, defacto, and if so, to see examples of it in the wild,
But if not, that's cool too, it will perhaps need more in-depth consideration as to standardization.
I've looked here https://clig.dev/ and it's very quiet in terms of return code handling, apart from:
"Return zero exit code on success, non-zero on failure. Exit codes are how scripts determine whether a program succeeded or failed, so you should report this correctly. Map the non-zero exit codes to the most important failure modes."
Is your feature request related to a problem? Please describe.
I would like to have a way to specify expected exit codes to be documented in the
--help
output, so that users know what codes to expect.Describe the solution you'd like
I suggest a method on the
ICommandConfigurator
interface like so for documenting exit codes:Describe alternatives you've considered
I currently add a block of text to my descriptions like so:
Which fits in quite nicely
However, the proposed solution above would mean the exit codes wouldn't need to appear between the description and the usages. I'd suggest the exit codes should appear last, after the options - but I'm open to thoughts. It also means that the formatting would be more standardised.
Additional context
Let me know if this is something you'd be open to receiving a PR for!
Thanks
Please upvote 👍 this issue if you are interested in it.
The text was updated successfully, but these errors were encountered: