Skip to content

Return EXIT_SUCCESS if no command provided#76

Merged
KrisThielemans merged 1 commit intoUCL:masterfrom
ghisvail:conda
May 30, 2021
Merged

Return EXIT_SUCCESS if no command provided#76
KrisThielemans merged 1 commit intoUCL:masterfrom
ghisvail:conda

Conversation

@ghisvail
Copy link
Contributor

I would like to use the petpvc command without arguments as a test command for the conda-forge package. However, that approach currently fails since not providing any command results in a docstring being printed to stdout and the program exiting with EXIT_FAILURE.

I am proposing to return EXIT_SUCCESS instead. This behaviour is aligned with modern CLI standards whereby calling an entry point without argument or with -h or --help should yield a description of the program and exit without errors.

I tried applying this patch to the conda-forge build and it works as intended.

@KrisThielemans
Copy link
Collaborator

could you check if this needs to be done in the other executables as well then please?

@ghisvail
Copy link
Contributor Author

As a regular user of CLI tools, I would expect all help calls to petpvc or petpvc <command> to stdout a docstring and return with EXIT_SUCCESS. EXIT_FAILURE should really happen when the user-specified arguments are inconsistent with what the CLI parser expects (missing required argument, wrong type of an argument, file not found...).

@ghisvail
Copy link
Contributor Author

I'll propagate the proposed fix to all commands then.

@ghisvail
Copy link
Contributor Author

It looks like only the petpvc entry-point has got something to print. The sub-commands just EXIT_FAILURE without output to stdout. In this case, I'd probably keep the current behavior as is for the sub-commands.

The best UX would be to print a contextual docstring for the specific command before returning EXIT_SUCCESS, but that's a larger scope than intended in this PR.

@KrisThielemans KrisThielemans merged commit 7ebe4bc into UCL:master May 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants