Open albertvaka opened 2 years ago
So if I am understanding this correctly, there are two parts to this...
InvalidUsageException(...)
that renders the message and also displays the usage help?Interesting idea.
It would be most helpful if yourself or anyone reading this could open a PR and link this issue, but also provide appropriate test coverage.
I assumed (1) was already the case, but I just saw it is not. So you are right, there are two parts to this FR.
To expand a bit more on (1), I do think it would be an improvement to error out if an unexpected argument is passed in (eg: because of a typo) instead of running and potentially doing the wrong thing. I even think it should be the default behavior, but I'm not sure if you would like to make that breaking change.
I can't promise I will be able to open a PR myself anytime soon, though, in case anyone else wants to give it a shoot :)
The pull request seems like a good implementation of this feature to me. Anything we can do to move forward with this issue?
It's a common pattern in CLI tools to print the help/usage if the arguments given are inconsistent or not valid.
This is something that can only be detected during the execution when the arguments are parsed and validated.
It would be useful to have a way to trigger the
print_task_help
function from the task itself (eg: by raising a specific exception) when that happens.