pyinvoke / invoke

Pythonic task management & command execution.
http://pyinvoke.org
BSD 2-Clause "Simplified" License
4.41k stars 369 forks source link

Show task help for InvalidUsageException and incorrect params #931

Open tyzhnenko opened 1 year ago

tyzhnenko commented 1 year ago

Example for a task that raises InvalidUsageException

@task
def invalid_usage_exception(c):
    from invoke import InvalidUsageException

    raise InvalidUsageException("Invalid task usage!")
Task invalid_usage_exception usage error: Invalid task usage!

Usage: invoke [--core-opts] invalid-usage-exception [other tasks here ...]

Docstring:
  none

Options:
  none

Example for a task that is called with absent parameter

@task(positional=["pos1", "pos2"])
def two_positionals(c, pos1, pos2, nonpos):
    pass
Usage: invoke [--core-opts] two-positionals [--options] [other tasks here ...]

Docstring:
  none

Options:
  -n STRING, --nonpos=STRING
  -o STRING, --pos2=STRING
  -p STRING, --pos1=STRING

'two-positionals' did not receive required positional arguments: 'pos1', 'pos2'

Issue: #857