UCL / PETPVC

Partial Volume Correction in PET
Apache License 2.0
50 stars 14 forks source link

Return EXIT_SUCCESS if no command provided #76

Closed ghisvail closed 3 years ago

ghisvail commented 3 years ago

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 commented 3 years ago

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

ghisvail commented 3 years ago

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 commented 3 years ago

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

ghisvail commented 3 years ago

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.