I can't think of any rationale for not having some help on command arguments, as this is the most basic requirement of such cli library.
So I hope I misused / did not understand how this library works.
Expected Behavior
When a command is decorated with @click.argument that contain a "help", an exception "unexpected keyword help" is raised.
Note that @click.option does accept the 'help' argument and the documentation says:
For @argument:
click.argument(*param_decls, **attrs)
Attaches an argument to the command. All positional arguments are passed as parameter declarations to Argument; all keyword arguments are forwarded unchanged (except cls). This is equivalent to creating an Argument instance manually and attaching it to the Command.params list.
and:
class click.Argument(param_decls, required=None, **attrs)
Arguments are positional parameters to a command. They generally provide fewer features than options but can have infinite nargs and are required by default.
All parameters are passed onwards to the parameter constructor.
For @option:
click.option(*param_decls, **attrs)
Attaches an option to the command. All positional arguments are passed as parameter declarations to Option; all keyword arguments are forwarded unchanged (except cls). This is equivalent to creating an Option instance manually and attaching it to the Command.params list.
class click.Option(param_decls=None, show_default=False, prompt=False, confirmation_prompt=False, hide_input=False, is_flag=None, flag_value=None, multiple=False, count=False, allow_from_autoenv=True, type=None, help=None, hidden=False, show_choices=True, show_envvar=False, **attrs)
Options are usually optional values on the command line and have some extra features that arguments don’t have.
The documentaiton is ambiguous, and there is no reason that help strings are limited to optional arguments. This functionality should be at the Parameter level and automatically inherited
import click
@click.command(name="cli")
@click.argument("test", help="A helper for test argument")
def myfunc(test):
pass
myfunc()
Actual Behavior
Error unexpected "help" keyword argument
Traceback (most recent call last):
File "/home/chris/.conda/envs/pe/lib/python3.6/site-packages/IPython/core/interactiveshell.py", line 3331, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-c99a68152a86>", line 2, in <module>
@click.argument("test", help="A helper for test argument")
File "/home/chris/.conda/envs/pe/lib/python3.6/site-packages/click/decorators.py", line 168, in decorator
_param_memo(f, ArgumentClass(param_decls, **attrs))
File "/home/chris/.conda/envs/pe/lib/python3.6/site-packages/click/core.py", line 1984, in __init__
Parameter.__init__(self, param_decls, required=required, **attrs)
TypeError: __init__() got an unexpected keyword argument 'help'
Environment
- Python version: 3.6
- Click version: 7.1.2 (build pyh9f0ad1d_0 on conda-forge)
I can't think of any rationale for not having some help on command arguments, as this is the most basic requirement of such cli library.
So I hope I misused / did not understand how this library works.
Expected Behavior
When a command is decorated with @click.argument that contain a "help", an exception "unexpected keyword help" is raised.
Note that @click.option does accept the 'help' argument and the documentation says:
For @argument:
click.argument(*param_decls, **attrs)
Attaches an argument to the command. All positional arguments are passed as parameter declarations to Argument; all keyword arguments are forwarded unchanged (except cls). This is equivalent to creating an Argument instance manually and attaching it to the Command.params list.
and:
class click.Argument(param_decls, required=None, **attrs)
Arguments are positional parameters to a command. They generally provide fewer features than options but can have infinite nargs and are required by default.
All parameters are passed onwards to the parameter constructor.
For @option:
click.option(*param_decls, **attrs)
Attaches an option to the command. All positional arguments are passed as parameter declarations to Option; all keyword arguments are forwarded unchanged (except cls). This is equivalent to creating an Option instance manually and attaching it to the Command.params list.
class click.Option(param_decls=None, show_default=False, prompt=False, confirmation_prompt=False, hide_input=False, is_flag=None, flag_value=None, multiple=False, count=False, allow_from_autoenv=True, type=None, help=None, hidden=False, show_choices=True, show_envvar=False, **attrs)
Options are usually optional values on the command line and have some extra features that arguments don’t have.
The documentaiton is ambiguous, and there is no reason that help strings are limited to optional arguments. This functionality should be at the Parameter level and automatically inherited
Actual Behavior
Error unexpected "help" keyword argument
Environment