Docs: fixes
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Julen Ruiz Aizpuru · committed by Julen Ruiz Aizpuru · parent 5381d65 · Browse files · 1 file·+10 added−10 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+10 added−10 removed
- other:+10 added−10 removed
Provenance
- Commit
52dad20- Tree
c6ae521- Author
Julen Ruiz Aizpuru <julenx@gmail.com>- Committer
Julen Ruiz Aizpuru <julenx@gmail.com>- Parent
5381d65
1 file changed+10 added−10 removed
modified:docs/advanced.rst+10 added-10 removed
123 unmodified lines124 Callback Evaluation Order125 -------------------------126 127 Click works a bit different than some other command line parsers in that128-it attempts to reconsiliate the order of arguments as defined by the128+it attempts to reconcile the order of arguments as defined by the129 programmer with the order of arguments as defined by the user before130 invoking any callbacks.131 132 This is an important concept to understand when implementing complex1 unmodified line134 callback invocation in optparse happens as part of the parsing step135 whereas a callback invocation in click happens after the parsing.136 137 The main difference is that in optparse callbacks are invoked with the raw138-value as it happens whereas a callback in click is invoked after the value139-as fully converted.138+value as it happens, whereas a callback in click is invoked after the139+value has been fully converted.140 141 Generally the order of invocation is driven by the order in which the user142 provides the arguments to the script. So if there is an option called143 ``--foo`` and an option called ``--bar`` and the user calls it as ``--bar144---foo`` then the callback for ``bar`` will fire before the one of ``foo``.144+--foo`` then the callback for ``bar`` will fire before the one for ``foo``.145 146 There are two exceptions to this rule which are important to know:147 148 Eagerness:1 unmodified line150 evaluated before all non-eager parameters, but again in the order as151 they were provided on the command line by the user.152 153 This is important for parameters that execute and exit like ``--help``154- and ``--version``. Both are eager parameters but whatever paramter154+ and ``--version``. Both are eager parameters but whatever parameter155 comes first on the command line will win and exit the program.156 157 Repeated parameters:158 If an option or argument is split up on the command line into multiple3 unmodified lines162 ``exclude`` and it will be passed both options (``foo`` and163 ``bar``), then the callback for ``include`` will fire with ``baz``164 only.165 166- Note that even if an parameter does not allow multiple versions click166+ Note that even if a parameter does not allow multiple versions, click167 will still accept the position of the first, but it will ignore every168- value with the exception of the first. The reason for this is to169- allow composability through shell aliases that set defaults.168+ value except the first. The reason for this is to allow composability169+ through shell aliases that set defaults.170 171 Missing parameters:172- If an parameter is not defined on the command line the callback will172+ If a parameter is not defined on the command line the callback will173 still fire. This is different from how it works in optparse where174- not defined values do not fire the callback. Missing parameters fire174+ undefined values do not fire the callback. Missing parameters fire175 their callbacks at the very end which makes it possible for them to176 default to values from a parameter that came before.177 178 Most of the time you don't need to be concerned about any of this stuff,1 unmodified line