Rewrite arguments docs more nicely.
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by unknown · committed by unknown · parent 82ffa4b · Browse files · 3 files·+14 added−12 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+14 added−12 removed
- other:+14 added−12 removed
Provenance
- Commit
424d0e7- Tree
e7d513d- Author
unknown <edward.g2013@gmail.com>- Committer
unknown <edward.g2013@gmail.com>- Parent
82ffa4b
3 files changed+14 added−12 removed
modified:docs/arguments.rst+11 added-11 removed
3 unmodified lines4 =========5 6 .. currentmodule:: click7 8+Arguments are:9 9-10 * Are positional in nature11-* Are very much like a limited version of :ref:`options <options>`12-* But also can take an arbitrary number of inputs13-* Must be :ref:`documented manually <documenting-arguments>`11+* Similar to a limited version of :ref:`options <options>` that can take an arbitrary number of inputs12+* :ref:`documented manually <documenting-arguments>`13 14 Useful and often used kwargs are:15 16 * ``default`` : Passes a default20 unmodified lines37 38 invoke(touch, args=['foo.txt'])39 40 42-Not sure if should include : If no type is provided, the type of the default value is used, and if no default value is provided, the type is assumed to be STRING.41+An argument may be assigned a :ref:`parameter type <parameter-types>`. If no type is provided, the type of the default value is used. If no default value is provided, the type is assumed to be STRING.42 43+.. admonition:: Note on Required Arguments44+45+ It is possible to make an argument required by setting ``required=True``. It is not recommended since we think command line tools should gracefully degrade into becoming no ops. We think this because command line tools are often invoked with wildcard inputs and they should not error out if the wildcard is empty.46+47 Multiple Arguments48 -----------------------------------49 50 To set the number of argument use the ``nargs`` kwarg. It can be set to any positive integer and -1. Setting it to -1, makes the number of arguments arbitrary (which is called variadic) and can only be used once. The arguments are then packed as a tuple and passed to the function.13 unmodified lines64 .. click:run::65 66 invoke(copy, args=['foo.txt', 'usr/david/foo.txt', 'usr/mitsuko/foo.txt'])67 68+.. admonition:: Note on Handling Files.65-Note this example is not how you would handle files and files paths, since it passes them in as strings. For more see :ref:`handling-files`.69+ This is not how you would handle files and files paths, since it passes them in as strings. For more see :ref:`handling-files`.70 67-.. admonition:: Note on Required Arguments68-69- It is not recommended, but you may make at least one argument required by setting ``required=True``. It is not recommended since we think command line tools should gracefully degrade into becoming noops. We think this because command line tools are often invoked with wildcard inputs and they should not error out if the wildcard is empty.70-71 Argument Escape Sequences72 ---------------------------73 74-If you want to process arguments that look like options, like a file named ``-foo.txt``, you must pass the ``--`` separator first. After you pass the ``--``, you may only pass arguments. This is a common feature for POSIX command line tools.74+If you want to process arguments that look like options, like a file named ``-foo.txt`` or ``--foo.txt`` , you must pass the ``--`` separator first. After you pass the ``--``, you may only pass arguments. This is a common feature for POSIX command line tools.75 76 Example usage:77 78 .. click:example::57 unmodified linesmodified:docs/index.rst+1 added-1 removed
71 unmodified lines72 setuptools73 parameters74 options75 arguments76- handling_files76 commands77 prompts78+ handling_files79 documentation80 complex81 advanced82 testing27 unmodified linesmodified:docs/parameters.rst+2 added
51 unmodified lines52 .. click:run::53 54 invoke(multi_echo, ['--times=3', 'index.txt'], prog_name='multi_echo')55 56+.. _parameter-types:57+58 Parameter Types59 ---------------60 61 The supported parameter types are:78 unmodified lines