Display subcommand in error messages#162
Conversation
When there is an error in the command line (such as an unknown option), this displays the command name instead of just the executable name. This is visible in the darcs example: `./darcs_ex.exe initialize --invalid` would previously display "darcs: unknown option '--invalid'", but now displays "darcs initialize: ...". This is also consistent with the `pp_try_help` path.
|
Did you check a bit with other command line tool with subcommands what they do ? The reason why this is so now is that's a message from the program and the current formatting basically follows the gnu convention. Not necessarily against it but the command name is already mentioned twice just below and your scheme leaves less space for the error message to be seen unwrapped. |
|
Both Git and Nix do not seem to display the name of the command at all. If there is an incomplete subcommand however, Nix will display the subcommand thusfar: e.g. $ nix profile
error: 'nix profile' requires a sub-command.
Try 'nix --help' for more information.however $ nix profile list -c
error: unrecognised flag '-c'
Try 'nix --help' for more information.Also $ git branch -m
fatal: branch name requiredSo I suppose if we are to write the command name in the error message, then it would make more sense to write the full subcommand. |
|
Thanks for the research @Alizter. So to sum up I'd like to keep the executable name prefix because it's useful to trace the source of errors in logs or script runs (and follows the gnu convention). I'm a bit less convinced that it's useful to add the subcommand name since it immediately follows in the sequel. I would tend to favour in making the most of the remaining 80 columns for the error message. |
|
Here's a concrete example that overflows (of course you will always have examples that do, even with the current scheme). and It may be a matter of taste but personally I find it easier to get in the first case that there is a problem and that the Namely for me Besides the functions that implement your sub commands are more likely to output errors using the gnu convention (the executable name is easy to reach for, the cmdliner subcommand a little bit less). So always using the program tool name only is likely to be less confusing than having the subcommands only on cli parse errors. I think I'm gravitating towards a let's not do that… |
|
Hi, |
When there is an error in the command line (such as an unknown option), this displays the command name instead of just the executable name.
This is visible in the darcs example:
./darcs_ex.exe initialize --invalidwould previously display "darcs: unknown option '--invalid'", but now displays "darcs initialize: ...".This is also consistent with the
pp_try_helppath.