U a@sdddlZddlZddlZddlZddlZddlZddlmZddlm Z ddlm Z ddl m Z ddl m Z ddlmZddlmZdd lmZd d lmZd d lmZd d lmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlmZd dlm Z d dl!m"Z"d dl!m#Z#d dl$m%Z%d dl$m&Z&d dl$m'Z'd dl(m)Z)d dl(m*Z*d dl(m+Z+d dl,m-Z-d dl,m.Z.d dl,m/Z/d d l,m0Z0d d!l,m1Z1d d"l,m2Z2ej3rddl4Z5d d#l6m7Z7ej8d$ej9d%ej:fd&Z;e8d'Zd,e?ej@ejAe?d-fd.d/d0ZBdSd2e?d-eCdd3d4d5ZDejEe<e=ejFejAed?ZKGd@dAdAejLZMGdBd,d,ZNGdCdDdDZOGdEd-d-eOZPGdFd2d2ePZQGdGdHdHeQZRGdIdJdJeQZSej:ej@ej:dKdLdMZTGdNd9d9ZUGdOdPdPeUZVGdQdRdReUZWdS)UN)abc)contextmanager) ExitStack)partial)update_wrapper)gettext)ngettext)repeat)types)_verify_python_envAbort) BadParameter)ClickExceptionExit)MissingParameter UsageError) HelpFormatter) join_options) pop_context) push_context)_flag_needs_value) OptionParser) split_opt)confirm)prompt)style)_detect_program_name) _expand_args)echo)make_default_short_help)make_str)PacifyFlushWrapperCompletionItemF.)boundV te.NoReturncodereturncCs"tjtjt|dS)zLow-level exit that skips Python's cleanup but speeds up exit by about 10ms for things like shell completion. :param code: Exit code. N)sysstdoutflushstderros_exit)r-r5KC:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-s9fh6ldx\click\core.py _fast_exit1s  r7ContextCommandctx incompleter.ccsPtt|j}||D]2}||r|||}|dk r|js||fVqdS)zList all the subcommands of a group that start with the incomplete value and aren't hidden. :param ctx: Invocation context for the group. :param incomplete: Value being completed. May be empty. N)tcast MultiCommandcommand list_commands startswith get_commandhidden)r;r<Zmultinamer@r5r5r6_complete_visible_commands<s   rFFr?) base_commandcmd_namecmdregisterr.cCsh|jrt|tsdS|rd}nd}t|d|jd|d|dt|jdt|jd|jd dS) NzdIt is not possible to add multi commands as children to another multi command that is in chain mode.zdFound a multi command as subcommand to a multi command that is in chain mode. This is not supported.z . Command z is set to chain and zA was added as a subcommand but it in itself is a multi command. (z is a z within a chained z named z).)chain isinstancer? RuntimeErrorrEtype__name__)rGrHrIrJhintr5r5r6_check_multicommandOsContext manager that attaches extra information to exceptions.N)rr;rZr)r;rZer5r5r6augment_usage_errorsks   r\)invocation_orderdeclaration_orderr.cs*dtjttfdfdd }t||dS)zGiven a sequence of parameters in the order as should be considered for processing and an iterable of parameters that exist, this returns a list in the correct order as they should be processed. rY)itemr.cs8z|}Wntk r*td}YnX|j |fS)Ninf)index ValueErrorfloatis_eager)r_idxr]r5r6sort_keys z,iter_params_for_processing..sort_keykey)r=Tupleboolrcsorted)r]r^rgr5rfr6iter_params_for_processing~s rmc@s8eZdZdZeZeZeZeZ eZ dS)ParameterSourcea\This is an :class:`~enum.Enum` that indicates the source of a parameter's value. Use :meth:`click.Context.get_parameter_source` to get the source for a parameter by name. .. versionchanged:: 8.0 Use :class:`~enum.Enum` and drop the ``validate`` method. .. versionchanged:: 8.0 Added the ``PROMPT`` value. N) rO __module__ __qualname____doc__enumauto COMMANDLINE ENVIRONMENTDEFAULT DEFAULT_MAPPROMPTr5r5r5r6rns rnc@s"eZdZUdZeZejded<dOdej dej e ej ej ej e ej ej e ej fej e ej e eej eej eej eej eje ej eje ge fej eej edddd Zej e ej fd d d Zdd d dZddZedPeejddddZeej e ej fd ddZed ddZejeedddZejdej fejdej fdddZdd d d!Zee d d"d#Z dd d$d%Z!ejeej ed&d'd(Z"ejeed&d)d*Z#e$j%dQe d+ej ej d,d-d.Z&e$j%dRe d/ej ej'ej ejgej ffd,d0d.Z&dSe eej ej d,d1d.Z&e d2d3d4d5Z(d2d d6d7Z)dTe d2d9d:d;Z*e d dd?Z,ddd@dAdBZ-ej'dejdej ffej ej ej dCdDdEZ.dej ej ej dFdGdHZ/e e0ddIdJdKZ1e ej e0dLdMdNZ2dS)Ur8aThe context is a special internal object that holds state relevant for the script execution at every single level. It's normally invisible to commands unless they opt-in to getting access to it. The context is useful as it can pass internal objects around and can control special execution features such as reading data from environment variables. A context can be used as context manager in which case it will call :meth:`close` on teardown. :param command: the command class for this context. :param parent: the parent context. :param info_name: the info name for this invocation. Generally this is the most descriptive name for the script or command. For the toplevel script it is usually the name of the script, for commands below it it's the name of the script. :param obj: an arbitrary object of user data. :param auto_envvar_prefix: the prefix to use for automatic environment variables. If this is `None` then reading from environment variables is disabled. This does not affect manually set environment variables which are always read. :param default_map: a dictionary (like object) with default values for parameters. :param terminal_width: the width of the terminal. The default is inherit from parent context. If no context defines the terminal width then auto detection will be applied. :param max_content_width: the maximum width for content rendered by Click (this currently only affects help pages). This defaults to 80 characters if not overridden. In other words: even if the terminal is larger than that, Click will not format things wider than 80 characters by default. In addition to that, formatters might add some safety mapping on the right. :param resilient_parsing: if this flag is enabled then Click will parse without any interactivity or callback invocation. Default values will also be ignored. This is useful for implementing things such as completion support. :param allow_extra_args: if this is set to `True` then extra arguments at the end will not raise an error and will be kept on the context. The default is to inherit from the command. :param allow_interspersed_args: if this is set to `False` then options and arguments cannot be mixed. The default is to inherit from the command. :param ignore_unknown_options: instructs click to ignore options it does not know and keeps them for later processing. :param help_option_names: optionally a list of strings that define how the default help parameter is named. The default is ``['--help']``. :param token_normalize_func: an optional function that is used to normalize tokens (options, choices, etc.). This for instance can be used to implement case insensitive behavior. :param color: controls if the terminal supports ANSI colors or not. The default is autodetection. This is only needed if ANSI codes are used in texts that Click prints which is by default not the case. This for instance would affect help output. :param show_default: Show defaults for all options. If not set, defaults to the value from a parent context. Overrides an option's ``show_default`` argument. .. versionchanged:: 8.0 The ``show_default`` parameter defaults to the value from the parent context. .. versionchanged:: 7.1 Added the ``show_default`` parameter. .. versionchanged:: 4.0 Added the ``color``, ``ignore_unknown_options``, and ``max_content_width`` parameters. .. versionchanged:: 3.0 Added the ``allow_extra_args`` and ``allow_interspersed_args`` parameters. .. versionchanged:: 2.0 Added the ``resilient_parsing``, ``help_option_names``, and ``token_normalize_func`` parameters. rformatter_classNFr9)r@parent info_nameobjauto_envvar_prefix default_mapterminal_widthmax_content_widthresilient_parsingallow_extra_argsallow_interspersed_argsignore_unknown_optionshelp_option_namestoken_normalize_funccolor show_defaultr.cCs||_||_||_i|_g|_g|_|dkr:|dk r:|j}||_t|di|_|dkr||dk r||dk r||j dk r||j |}||_ d|_ |dkr|dk r|j }||_ |dkr|dk r|j }||_ | dkr|j} | |_| dkr|j} | |_| dkr|j} | |_| dkr|dk r|j} ndg} | |_|dkr>|dk r>|j}||_| |_|dkr|dk r|jdk r|jdk r|jd|j}n|}|dk r|dd}||_|dkr|dk r|j}||_|dkr|dk r|j}||_g|_d|_i|_t|_dS)Nmetaz--help_-r)rzr@r{paramsargsprotected_argsr|getattr_metar~getinvoked_subcommandrrrrrrrrr}upperreplacerrZ_close_callbacks_depth_parameter_sourcer _exit_stack)selfr@rzr{r|r}r~rrrrrrrrrrr5r5r6__init__ s        zContext.__init__r.cCs$|j||j|j|j|j|jdS)a*Gather information that could be useful for a tool generating user-facing documentation. This traverses the entire CLI structure. .. code-block:: python with Context(cli) as ctx: info = ctx.to_info_dict() .. versionadded:: 8.0 )r@r{rrrr})r@ to_info_dictr{rrrr}rr5r5r6rs zContext.to_info_dictcCs|jd7_t||SNr )rrrr5r5r6 __enter__szContext.__enter__cCs*|jd8_|jdkr |tdSNr r)rcloser)rexc_type exc_valuetbr5r5r6__exit__s zContext.__exit__T)cleanupr.c csF|s|jd7_z| }|VW5QRXW5|s@|jd8_XdS)aIThis helper method can be used with the context object to promote it to the current thread local (see :func:`get_current_context`). The default behavior of this is to invoke the cleanup functions which can be disabled by setting `cleanup` to `False`. The cleanup functions are typically used for things such as closing file handles. If the cleanup is intended the context object can also be directly used as a context manager. Example usage:: with ctx.scope(): assert get_current_context() is ctx This is equivalent:: with ctx: assert get_current_context() is ctx .. versionadded:: 5.0 :param cleanup: controls if the cleanup functions should be run or not. The default is to run these functions. In some situations the context only wants to be temporarily pushed in which case this can be disabled. Nested pushes automatically defer the cleanup. r N)r)rrrvr5r5r6scopesz Context.scopecCs|jS)aThis is a dictionary which is shared with all the contexts that are nested. It exists so that click utilities can store some state here if they need to. It is however the responsibility of that code to manage this dictionary well. The keys are supposed to be unique dotted strings. For instance module paths are a good choice for it. What is stored in there is irrelevant for the operation of click. However what is important is that code that places data here adheres to the general semantics of the system. Example usage:: LANG_KEY = f'{__name__}.lang' def set_language(value): ctx = get_current_context() ctx.meta[LANG_KEY] = value def get_language(): return get_current_context().meta.get(LANG_KEY, 'en_US') .. versionadded:: 5.0 )rrr5r5r6rsz Context.metacCs|j|j|jdS)a=Creates the :class:`~click.HelpFormatter` for the help and usage output. To quickly customize the formatter class used without overriding this method, set the :attr:`formatter_class` attribute. .. versionchanged:: 8.0 Added the :attr:`formatter_class` attribute. )width max_width)ryrrrr5r5r6make_formatters zContext.make_formatter)context_managerr.cCs |j|S)aRegister a resource as if it were used in a ``with`` statement. The resource will be cleaned up when the context is popped. Uses :meth:`contextlib.ExitStack.enter_context`. It calls the resource's ``__enter__()`` method and returns the result. When the context is popped, it closes the stack, which calls the resource's ``__exit__()`` method. To register a cleanup function for something that isn't a context manager, use :meth:`call_on_close`. Or use something from :mod:`contextlib` to turn it into a context manager first. .. code-block:: python @click.group() @click.option("--name") @click.pass_context def cli(ctx): ctx.obj = ctx.with_resource(connect_db(name)) :param context_manager: The context manager to enter. :return: Whatever ``context_manager.__enter__()`` returns. .. versionadded:: 8.0 )r enter_context)rrr5r5r6 with_resource%szContext.with_resource.fr.cCs |j|S)aRegister a function to be called when the context tears down. This can be used to close resources opened during the script execution. Resources that support Python's context manager protocol which would be used in a ``with`` statement should be registered with :meth:`with_resource` instead. :param f: The function to execute on teardown. )rcallback)rrr5r5r6 call_on_closeBs zContext.call_on_closecCs|jt|_dS)zInvoke all close callbacks registered with :meth:`call_on_close`, and exit all context managers entered with :meth:`with_resource`. N)rrrrr5r5r6rNs z Context.closecCsvd}|jdk r|j}|jdk rn|jjg}t|jjtrZ|jj|D]}|||qDd |d|}| S)zThe computed command path. This is used for the ``usage`` information on the help page. It's automatically created by combining the info names of the chain of contexts to the root. N ) r{rz command_pathrLr@r9 get_paramsextendget_usage_piecesjoinlstrip)rrZparent_command_pathrZr5r5r6rWs   zContext.command_pathcCs|}|jdk r|j}q|S)zFinds the outermost context.Nrz)rnoder5r5r6 find_rootjs zContext.find_root) object_typer.cCs*|}|dk r&t|j|r|jS|j}qdS)z)Finds the closest object of a given type.N)rLr|rz)rrrr5r5r6 find_objectqs  zContext.find_objectcCs"||}|dkr||_}|S)zLike :meth:`find_object` but sets the innermost object to a new instance of `object_type` if it does not exist. N)rr|)rrrr5r5r6 ensure_object}s  zContext.ensure_objectte.Literal[True])rEcallr.cCsdSrTr5rrErr5r5r6lookup_defaultszContext.lookup_defaultzte.Literal[False]cCsdSrTr5rr5r5r6rscCs0|jdk r,|j|}|r(t|r(|S|SdS)a*Get the default for a parameter from :attr:`default_map`. :param name: Name of the parameter. :param call: If the default is a callable, call it. Disable to return the callable instead. .. versionchanged:: 8.0 Added the ``call`` parameter. N)r~rcallable)rrErvaluer5r5r6rs   r+)messager.cCst||dS)zAborts the execution of the program with a specific error message. :param message: the error message to fail with. Nr)rrr5r5r6failsz Context.failcCs tdS)zAborts the script.Nr rr5r5r6abortsz Context.abortrr,cCs t|dS)z-Exits the application with a given exit code.Nr)rr-r5r5r6exitsz Context.exitcCs |j|S)zaHelper method to get formatted usage string for the current context and command. )r@ get_usagerr5r5r6rszContext.get_usagecCs |j|S)z^Helper method to get formatted help page for the current context and command. )r@get_helprr5r5r6rszContext.get_help)r@r.cCst|||j|dS)zvCreate a new context of the same type as this context, but for a new command. :meta private: r{rz)rNrE)rr@r5r5r6_make_sub_contextszContext._make_sub_context)_Context__callbackrkwargsr.c Ost|trl|}|jdkr"tdn|j}||}|jD]$}|j|kr8|jr8||||j<q8|j |n|}t |4|$|||W5QRW5QRSQRXW5QRXdS)aInvokes a command callback in exactly the way it expects. There are two ways to invoke this method: 1. the first argument can be a callback and all other arguments and keyword arguments are forwarded directly to the function. 2. the first argument is a click command object. In that case all arguments are forwarded as well but proper click parameters (options and click arguments) must be keyword arguments and Click will fill in defaults. Note that before Click 3.2 keyword arguments were not properly filled in against the intention of this code and no context was created. For more information about this change and why it was done in a bugfix release see :ref:`upgrade-to-3.2`. .. versionchanged:: 8.0 All ``kwargs`` are tracked in :attr:`params` so they will be passed if :meth:`forward` is called at multiple levels. Nz?The given command does not have a callback that can be invoked.) rLr9r TypeErrorrrrE expose_value get_defaultupdater\)_Context__selfrrrZ other_cmdr;rZr5r5r6invokes      zContext.invoke) _Context__cmdrrr.cOsFt|tstd|jD]}||kr|j|||<q|j|f||S)azSimilar to :meth:`invoke` but fills in default keyword arguments from the current context if the other command expects it. This cannot invoke callbacks directly, only other commands. .. versionchanged:: 8.0 All ``kwargs`` are tracked in :attr:`params` so they will be passed if ``forward`` is called at multiple levels. zCallback is not a command.)rLr9rrr)rrrrrZr5r5r6forwards  zContext.forward)rEsourcer.cCs||j|<dS)zSet the source of a parameter. This indicates the location from which the value of the parameter was obtained. :param name: The name of the parameter. :param source: A member of :class:`~click.core.ParameterSource`. N)r)rrErr5r5r6set_parameter_sourceszContext.set_parameter_source)rEr.cCs |j|S)aXGet the source of a parameter. This indicates the location from which the value of the parameter was obtained. This can be useful for determining when a user specified a value on the command line that is the same as the default value. It will be :attr:`~click.core.ParameterSource.DEFAULT` only if the value was actually taken from the default. :param name: The name of the parameter. :rtype: ParameterSource .. versionchanged:: 8.0 Returns ``None`` if the parameter was not provided from any source. )rr)rrEr5r5r6get_parameter_sourceszContext.get_parameter_source)NNNNNNNFNNNNNNN)T)T).)T)r)3rOrorprqrryr=Type__annotations__OptionalstrAnyDictintrkListCallablerrrrrIteratorrpropertyrrContextManagerr*rrrrrrrtypingoverloadrUnionrrrrrrrrrnrrr5r5r5r6r8s \  +%(        4  c @seZdZUdZeZejeed<dZ dZ dZ d.ej e ej eje ejfddddZeeje ejfd d d Ze d d dZee d ddZee d ddZd/ej e eje ej eejedddZeeje eje dddZeejd ddZee ejddddZejd0ej eje ej e ej e dejd d!d"d#Zejd1ej eje ej e ej e eejejd!d%d#Zd2ej eje ej e ej e eeejejd&d'd#Zd3eje ejfe ej e dd(d)d*Zejejejd+d,d-Z dS)4 BaseCommandaThe base command implements the minimal API contract of commands. Most code will never use this as it does not implement a lot of useful functionality but it can act as the direct subclass of alternative parsing methods that do not depend on the Click parser. For instance, this can be used to bridge Click and other systems like argparse or docopt. Because base commands do not implement a lot of the API that other parts of Click take for granted, they are not supported for all operations. For instance, they cannot be used with the decorators usually and they have no built-in callback system. .. versionchanged:: 2.0 Added the `context_settings` parameter. :param name: the name of the command to use unless a group overrides it. :param context_settings: an optional dictionary with defaults that are passed to the context object. context_classFTN)rEcontext_settingsr.cCs||_|dkri}||_dSrT)rEr)rrErr5r5r6rOs zBaseCommand.__init__r;r.cCs d|jiS)aiGather information that could be useful for a tool generating user-facing documentation. This traverses the entire structure below this command. Use :meth:`click.Context.to_info_dict` to traverse the entire CLI structure. :param ctx: A :class:`Context` representing this command. .. versionadded:: 8.0 rErErr;r5r5r6r`s zBaseCommand.to_info_dictrcCsd|jjd|jdSN __class__rOrErr5r5r6__repr__nszBaseCommand.__repr__cCs tddS)NzBase commands cannot get usageNotImplementedErrorrr5r5r6rqszBaseCommand.get_usagecCs tddS)NzBase commands cannot get helprrr5r5r6rtszBaseCommand.get_help)r{rrzextrar.c Ksd|jD]\}}||kr |||<q |j|f||d|}|jdd|||W5QRX|S)aThis function when given an info name and arguments will kick off the parsing and create a new :class:`Context`. It does not invoke the actual command callback though. To quickly customize the context class used without overriding this method, set the :attr:`context_class` attribute. :param info_name: the info name for this invocation. Generally this is the most descriptive name for the script or command. For the toplevel script it's usually the name of the script, for commands below it it's the name of the command. :param args: the arguments to parse as list of strings. :param parent: the parent context if available. :param extra: extra keyword arguments forwarded to the context constructor. .. versionchanged:: 8.0 Added the :attr:`context_class` attribute. rFr)ritemsrr parse_args)rr{rrzrrirr;r5r5r6 make_contextws zBaseCommand.make_contextr;rr.cCs tddS)zGiven a context and a list of arguments this creates the parser and parses the arguments, then modifies the context as necessary. This is automatically invoked by :meth:`make_context`. z1Base commands do not know how to parse arguments.Nr)rr;rr5r5r6rszBaseCommand.parse_argscCs tddS)z{Given a context, this invokes the command. The default implementation is raising a not implemented error. z*Base commands are not invokable by defaultNrrr5r5r6rszBaseCommand.invoker'r:csZddlmg}jdk rVjtjtrjjr|fddt|Dq|S)aReturn a list of completions for the incomplete value. Looks at the names of chained multi-commands. Any command could be part of a chained multi-command, so sibling commands are valid at any point during command completion. Other command classes will return more completions. :param ctx: Invocation context for this command. :param incomplete: Value being completed. May be empty. .. versionadded:: 8.0 rr&Nc3s,|]$\}}|jkr||dVqdShelpN)rget_short_help_str.0rEr@r'r;r5r6 s z-BaseCommand.shell_complete..) click.shell_completionr'rzrLr@r?rKrrFrr;r<resultsr5rr6shell_completes   zBaseCommand.shell_completerr+)r prog_name complete_varstandalone_moderr.cKsdSrTr5rrr r r rr5r5r6mains zBaseCommand.main.cKsdSrTr5r r5r5r6rs )rr r r windows_expand_argsrr.c Kst|dkr4tjdd}tjdkr<|r_COMPLETE"`` with prog_name in uppercase. :param standalone_mode: the default behavior is to invoke the script in standalone mode. Click will then handle exceptions and convert them into error messages and the function will never return but shut down the interpreter. If this is set to `False` they will be propagated to the caller and the return value of this function is the return value of :meth:`invoke`. :param windows_expand_args: Expand glob patterns, user dir, and env vars in command line args on Windows. :param extra: extra keyword arguments are forwarded to the context constructor. See :class:`Context` for more information. .. versionchanged:: 8.0.1 Added the ``windows_expand_args`` parameter to allow disabling command line arg expansion on Windows. .. versionchanged:: 8.0 When taking arguments from ``sys.argv`` on Windows, glob patterns, user dir, and env vars are expanded. .. versionchanged:: 3.0 Added the ``standalone_mode`` parameter. Nr nt)filezAborted!)r r/argvr3rEr!rUr _main_shell_completionrrrEOFErrorKeyboardInterruptr"r2rrshowZ exit_codeOSErrorerrnoEPIPEr=r>TextIOr%r0rr) rrr r r rrr;rr[r5r5r6rsN5      )ctx_argsr r r.cCs\|dkr d|ddd}tj|}|s4dSddlm}||||||}t|dS)aCheck if the shell is asking for tab completion, process that, then exit early. Called from :meth:`main` before the program is invoked. :param prog_name: Name of the executable in the shell. :param complete_var: Name of the environment variable that holds the completion instruction. Defaults to ``_{PROG_NAME}_COMPLETE``. NrZ _COMPLETErr )r )rrr3environrshell_completionr r7)rrr r Z instructionr rr5r5r6rSs  z"BaseCommand._main_shell_completionrrr.cOs |j||S)zAlias for :meth:`main`.)r)rrrr5r5r6__call__oszBaseCommand.__call__)N)N)NNNT)NNN.)NNNTT)N)!rOrorprqr8rr=rrrrrrrrrrrrrrrrrrr rrSequencerrkrrr5r5r5r6r.s   '   y rcseZdZdZd5ejeejejeejfejej dejfejej dejeejeejeejee e e e dd fd d Z e ejeejfd fd d Ze ed ddZe ej dd ddZe eddddZe ej ed ddZe ej ed ddZe ejdd ddZe ed ddZe ed ddZd6eed!d"d#Ze eddd$d%Ze eddd&d'Ze eddd(d)Ze eddd*d+Ze ej eej ed,d-d.Ze ejd d/d0Z e eej d1d2fd3d4 Z!Z"S)7r9aCommands are the basic building block of command line interfaces in Click. A basic command handles command line parsing and might dispatch more parsing to commands nested below it. .. versionchanged:: 2.0 Added the `context_settings` parameter. .. versionchanged:: 8.0 Added repr showing the command name .. versionchanged:: 7.1 Added the `no_args_is_help` parameter. :param name: the name of the command to use unless a group overrides it. :param context_settings: an optional dictionary with defaults that are passed to the context object. :param callback: the callback to invoke. This is optional. :param params: the parameters to register with this command. This can be either :class:`Option` or :class:`Argument` objects. :param help: the help string to use for this command. :param epilog: like the help string but it's printed at the end of the help page after everything else. :param short_help: the short help to use for this command. This is shown on the command listing of the parent command. :param add_help_option: by default each command registers a ``--help`` option. This can be disabled by this parameter. :param no_args_is_help: this controls what happens if no arguments are provided. This option is disabled by default. If enabled this will add ``--help`` as argument if no arguments are passed :param hidden: hide this command from help outputs. :param deprecated: issues a message indicating that the command is deprecated. N [OPTIONS]TF.rY) rErrrrepilog short_helpoptions_metavaradd_help_optionno_args_is_helprD deprecatedr.c snt||||_|pg|_|r:d|kr:|ddd}||_||_||_||_| |_ | |_ | |_ | |_ dS)N r r) superrrrsplitrr"r$r#r%r&rDr') rrErrrrr"r#r$r%r&rDr'rr5r6rs  zCommand.__init__rcs@t|}|jdd||D|j|j|j|j|jd|S)NcSsg|] }|qSr5)r)rrZr5r5r6 sz(Command.to_info_dict..)rrr"r#rDr') r)rrrrr"r#rDr')rr; info_dictr+r5r6rs zCommand.to_info_dictcCs"|}||||dS)zmFormats the usage line into a string and returns it. Calls :meth:`format_usage` internally.  )r format_usagegetvaluerstriprr; formatterr5r5r6rs zCommand.get_usagecCs&|j}||}|dk r"||f}|SrT)rget_help_option)rr;r help_optionr5r5r6rs   zCommand.get_paramsr;r3r.cCs"||}||jd|dS)zsWrites the usage line into the formatter. This is a low-level method called by :meth:`get_usage`. rN)collect_usage_piecesZ write_usagerr)rr;r3piecesr5r5r6r/s zCommand.format_usagecCs6|jr|jgng}||D]}|||q|S)zhReturns all the pieces that go into the usage line and returns it as a list of strings. )r$rrr)rr;rrZr5r5r6r7szCommand.collect_usage_piecescCs6t|j}|jD]}||j||jqt|S)z&Returns the names for the help option.)setrrdifference_updateoptssecondary_optsrU)rr;Z all_namesrZr5r5r6get_help_option_namess    zCommand.get_help_option_namesOptioncCsD||}|r|jsdStdtdddd}t|ddd|tdd S) zReturns the help option object.NrY)r;rZrr.cSs(|r$|js$t||jd|dS)Nr)rr"rrr)r;rZrr5r5r6 show_helps z*Command.get_help_option..show_helpTFzShow this message and exit.)is_flagrdrrr)r=r%r8rr>r)rr; help_optionsr@r5r5r6r4s  zCommand.get_help_optioncCs(t|}||D]}|||q|S)z6Creates the underlying option parser for this command.)rr add_to_parser)rr;parserrZr5r5r6 make_parser szCommand.make_parsercCs"|}||||dS)zfFormats the help into a string and returns it. Calls :meth:`format_help` internally. r.)r format_helpr0r1r2r5r5r6rs zCommand.get_help-)limitr.cCs>|jpd}|s |jr t|j|}|jr6tdj|d}|S)z`Gets short help for the command or makes it by shortening the long help string. r(Deprecated) {text}text)r#rr#r'rformatstrip)rrHrKr5r5r6rs    zCommand.get_short_help_strcCs4||||||||||||dS)a0Writes the help into the formatter if it exists. This is a low-level method called by :meth:`get_help`. This calls the following methods: - :meth:`format_usage` - :meth:`format_help_text` - :meth:`format_options` - :meth:`format_epilog` N)r/format_help_textformat_options format_epilogr2r5r5r6rF)s   zCommand.format_helpc CsN|jpd}|jr tdj|d}|rJ||||W5QRXdS)z3Writes the help text to the formatter if it exists.rrIrJN)rr'rrLwrite_paragraph indentation write_text)rr;r3rKr5r5r6rN:s  zCommand.format_help_textc Cs\g}||D] }||}|dk r||q|rX|td||W5QRXdS)z8Writes all the options into the formatter if they exist.NOptions)rget_help_recordappendsectionrwrite_dl)rr;r3r;rZrr5r5r6rOGs  zCommand.format_optionsc Cs2|jr.||||jW5QRXdS)z2Writes the epilog into the formatter if it exists.N)r"rQrRrSr2r5r5r6rPSs zCommand.format_epilogrcCs|s*|jr*|js*t||jd|||}|j|d\}}}t|| |D]}| |||\}}qV|r|j s|js| t ddt|jdtt|d||_|S)Nr?)rz&Got unexpected extra argument ({args})z'Got unexpected extra arguments ({args})r)r&rr"rrrrErrmrhandle_parse_resultrrrlenrLrmaprr)rr;rrDr;Z param_orderrZrr5r5r6rZs& zCommand.parse_argscCsL|jr,tdj|jd}tt|dddd|jdk rH|j|jf|jSdS)zeGiven a context, this invokes the attached callback (if it exists) in the right way. z7DeprecationWarning: The command {name!r} is deprecated.rred)ZfgT)errN) r'rrLrEr"rrrr)rr;rr5r5r6rqs zCommand.invoker'r:csddlmg}r~ds~||D]Rttr*js*jsX|j t j krXq*| fddj jDq*| t||S)aReturn a list of completions for the incomplete value. Looks at the names of options and chained multi-commands. :param ctx: Invocation context for this command. :param incomplete: Value being completed. May be empty. .. versionadded:: 8.0 rr&c3s&|]}|r|jdVqdSr)rBr)rrEr'r<rZr5r6rs z)Command.shell_complete..)rr'isalnumrrLr>rDmultiplerrErnrtrr;r<r)r rr+r^r6r ~s(    zCommand.shell_complete) NNNNNNr!TFFF)rG)#rOrorprqr=rrrrrrrkrr8rrrrr/r7r=r4rrErrrrFrNrOrPrrr  __classcell__r5r5r+r6r9tsX%&        c seZdZdZdZdZd(ejee eje ejee ejej dej fej ddfdd Z e ejeej fd fd d Ze ejed fd d Ze eddfdd Zd)e ej egefdddZd*e ej egefdddZe eddddZe ejeejedfdd Ze ej d fdd Ze ejeejejeejeejefdddZe eejedd d!Ze ejed d"d#Ze eejd$d%fd&d' ZZ S)+r?aYA multi command is the basic implementation of a command that dispatches to subcommands. The most common version is the :class:`Group`. :param invoke_without_command: this controls how the multi command itself is invoked. By default it's only invoked if a subcommand is provided. :param no_args_is_help: this controls what happens if no arguments are provided. This option is enabled by default if `invoke_without_command` is disabled or disabled if it's enabled. If enabled this will add ``--help`` as argument if no arguments are passed. :param subcommand_metavar: the string that is used in the documentation to indicate the subcommand place. :param chain: if this is set to `True` chaining of multiple subcommands is enabled. This restricts the form of commands in that they cannot have optional arguments but it allows multiple commands to be chained together. :param result_callback: The result callback to attach to this multi command. This can be set or changed later with the :meth:`result_callback` decorator. TFN.)rEinvoke_without_commandr&subcommand_metavarrKresult_callbackattrsr.c  stj|f||dkr| }||_||_|dkr@|r.decorator..function)rfrr=r>r()rrorrrrnr6 decorators z/MultiCommand.result_callback..decorator)r()rrrqr5rpr6rdszMultiCommand.result_callbackcCs$ddl}|jdtdd|j|dS)Nrzb'resultcallback' has been renamed to 'result_callback'. The old name will be removed in Click 8.1. stacklevel)r)warningswarnDeprecationWarningrd)rrrur5r5r6resultcallback,szMultiCommand.resultcallbackc Csg}||D]0}|||}|dkr(q|jr0q|||fqt|r|jdtdd|D}g}|D] \}}||}|||fql|r|t d| |W5QRXdS)zeExtra format methods for multi methods that adds all the commands after the options. Ncss|]}t|dVqdS)rNrZ)rrIr5r5r6rHsz/MultiCommand.format_commands..Commands) rArCrDrVrZrmaxrrWrrX) rr;r3ri subcommandrIrHrowsrr5r5r6rl7s"   zMultiCommand.format_commandsrcst|s*|jr*|js*t||jd|t||}|jrL||_ g|_ n"|rn|dd|dd|_ |_ |j S)Nr?r ) r&rr"rrrr)rrKrr)rr;rrestr+r5r6rSszMultiCommand.parse_argsc stjtjdfdd }jsjjr\,t|jrDgndW5QRSQRXtdjj }g_ g_jsz |\}}}|dk st |_ t|j ||d}|*||j|W5QRW5QRSQRXW5QRX|rdnd_ tg}|r |\}}}|dk sZt |j ||ddd }|||j g}|_ q4g}|D](}|||j|W5QRXq||W5QRSQRXdS) Nrr.cs"jdk rjj|fj}|SrT)rfrrrr;rr5r6_process_resultcs z,MultiCommand.invoke.._process_resultzMissing command.r*TF)rzrr)r=rrrbr)rrKrrrresolve_commandAssertionErrorrrr@rV) rr;rrrHrIrjZcontextsrr+rr6rbsP $   8   zMultiCommand.invokecCst|d}|}|||}|dkrD|jdk rD||}|||}|dkr|jst|drl|||j|tdj |d|r|nd||ddfS)NrzNo such command {name!r}.rr ) r$rCrrrrrrrrL)rr;rrHZoriginal_cmd_namerIr5r5r6rs     zMultiCommand.resolve_commandr;rHr.cCstdS)z{Given a context and a command name, this returns a :class:`Command` object if it exists or returns `None`. Nrrr;rHr5r5r6rCszMultiCommand.get_commandcCsgS)zTReturns a list of subcommand names in the order they should appear. r5rr5r5r6rAszMultiCommand.list_commandsr'r:cs<ddlmfddt||D}|t|||S)a0Return a list of completions for the incomplete value. Looks at the names of options, subcommands, and chained multi-commands. :param ctx: Invocation context for this command. :param incomplete: Value being completed. May be empty. .. versionadded:: 8.0 rr&cs g|]\}}||dqS)r)rrr&r5r6r,sz/MultiCommand.shell_complete..)rr'rFrr)r rr+r&r6r s  zMultiCommand.shell_complete)NFNNFN)F)F)!rOrorprqrrr=rrrkrrrr8rrrr7rrOr(rdrxrlrrrjr9rrCrAr rar5r5r+r6r?sD& - "E cs<eZdZUdZdZejejee d<dZ ejej ejdeje fe d<deje ejej eje efejefejddfdd Zdeeje ddd d Zejejejejd ejfgefd d dZejejejejd ejfgdfd ddZee ejedddZeeje dddZZS)GroupaNA group allows a command to have subcommands attached. This is the most common way to implement nesting in Click. :param name: The name of the group command. :param commands: A dict mapping names to :class:`Command` objects. Can also be a list of :class:`Command`, which will use :attr:`Command.name` to create the dict. :param attrs: Other command arguments described in :class:`MultiCommand`, :class:`Command`, and :class:`BaseCommand`. .. versionchanged:: 8.0 The ``commmands`` argument can be a list of command objects. N command_class group_class)rErirer.c sBtj|f||dkri}nt|tjr8dd|D}||_dS)NcSsi|]}|jdk r|j|qSrTrrcr5r5r6 s z"Group.__init__..)r)rrLrr ri)rrErirer+r5r6rs  zGroup.__init__)rIrEr.cCs8|p|j}|dkrtdt|||dd||j|<dS)zRegisters another :class:`Command` with this group. If the name is not provided, the name of the command is used. NzCommand has no name.T)rJ)rErrQri)rrIrEr5r5r6 add_commands  zGroup.add_command.rcsRddlmjdk r(dkr(jd<tjdtjftdfdd }|S) aA shortcut decorator for declaring and attaching a command to the group. This takes the same arguments as :func:`command` and immediately registers the created command with this group by calling :meth:`add_command`. To customize the command class used, set the :attr:`command_class` attribute. .. versionchanged:: 8.0 Added the :attr:`command_class` attribute. r )r@Ncls.rcs|}||SrTrrrIrr@rrr5r6rq2s z Group.command..decorator) decoratorsr@rr=rrr9rrrrqr5rr6r@s   &z Group.commandcsjddlmjdk r@dkr@jtkr6td<n jd<tjdtjfddfdd }|S) aA shortcut decorator for declaring and attaching a group to the group. This takes the same arguments as :func:`group` and immediately registers the created group with this group by calling :meth:`add_command`. To customize the group class used, set the :attr:`group_class` attribute. .. versionchanged:: 8.0 Added the :attr:`group_class` attribute. r )groupNr.rrcs|}||SrTrrrrrrr5r6rqOs zGroup.group..decorator)rrrrNr=rrrr5rr6r9s   &z Group.grouprcCs |j|SrT)rirrr5r5r6rCVszGroup.get_commandrcCs t|jSrT)rlrirr5r5r6rAYszGroup.list_commands)NN)N)rOrorprqrr=rrr9rrrrNrrr rrrrr@rr8rCrrArar5r5r+r6rs,  ("   rcseZdZdZdejeejejeej ddfdd Z eddddZ e eeje d d d Ze ejed d dZZS)CommandCollectionaA command collection is a multi command that merges multiple multi commands together into one. This is a straightforward implementation that accepts a list of different multi commands as sources and provides all the commands for each of them. N)rEsourcesrer.c stj|f||pg|_dSrT)r)rr)rrErrer+r5r6rdszCommandCollection.__init__) multi_cmdr.cCs|j|dS)z1Adds a new multi command to the chain dispatcher.N)rrV)rrr5r5r6 add_sourcenszCommandCollection.add_sourcercCs>|jD]2}|||}|dk r|jr0t||||SqdSrT)rrCrKrQ)rr;rHrrr5r5r6rCrs    zCommandCollection.get_commandrcCs*t}|jD]}|||q t|SrT)r9rrrArl)rr;rrr5r5r6rA~s zCommandCollection.list_commands)NN)rOrorprqr=rrrr?rrrr8r9rCrArar5r5r+r6r]s  rrcCst|trtt|S)ztCheck if the value is iterable but not a string. Raises a type error, or return an iterator over the value. )rLrrrWrr5r5r6 _check_iters rc@sbeZdZdZdZdee ejej ej ejgej ffdddZd?ee ejej ej ejgej ffdddZeeddddZeej eej fejej e!fd d!d"Z"eej ej d#d$d%Z#ej e d&d'd(Z$eej ej d#d)d*Z%eejed+d,d-Z&eejej d+d.d/Z'eej eej fejeejej ejefd0d1d2Z(eejejeefd+d3d4Z)eejed+d5d6Z*eed+d7d8Z+eeejdd9d:d;Z,dS)@rYaA parameter to a command comes in two versions: they are either :class:`Option`\s or :class:`Argument`\s. Other subclasses are currently not supported by design as some of the internals for parsing are intentionally not finalized. Some settings are supported by both options and arguments. :param param_decls: the parameter declarations for this option or argument. This is a list of flags or argument names. :param type: the type that should be used. Either a :class:`ParamType` or a Python type. The later is converted into the former automatically if supported. :param required: controls if this is optional or not. :param default: the default value if omitted. This can also be a callable, in which case it's invoked when the default is needed without any arguments. :param callback: A function to further process or validate the value after type conversion. It is called as ``f(ctx, param, value)`` and must return the value. It is called for all sources, including prompts. :param nargs: the number of arguments to match. If not ``1`` the return value is a tuple instead of single value. The default for nargs is ``1`` (except if the type is a tuple, then it's the arity of the tuple). If ``nargs=-1``, all remaining parameters are collected. :param metavar: how the value is represented in the help page. :param expose_value: if this is `True` then the value is passed onwards to the command callback and stored on the context, otherwise it's skipped. :param is_eager: eager values are processed before non eager ones. This should not be set for arguments or it will inverse the order of processing. :param envvar: a string or list of strings that are environment variables that should be checked. :param shell_complete: A function that returns custom shell completions. Used instead of the param's type completion if given. Takes ``ctx, param, incomplete`` and must return a list of :class:`~click.shell_completion.CompletionItem` or a list of strings. .. versionchanged:: 8.0 ``process_value`` validates required parameters and bounded ``nargs``, and invokes the parameter callback before returning the value. This allows the callback to validate prompts. ``full_process_value`` is removed. .. versionchanged:: 8.0 ``autocompletion`` is renamed to ``shell_complete`` and has new semantics described above. The old name is deprecated and will be removed in 8.1, until then it will be wrapped to match the new requirements. .. versionchanged:: 8.0 For ``multiple=True, nargs>1``, the default must be a list of tuples. .. versionchanged:: 8.0 Setting a default is no longer required for ``nargs>1``, it will default to ``None``. ``multiple=True`` or ``nargs=-1`` will default to ``()``. .. versionchanged:: 7.1 Empty environment variables are ignored rather than taking the empty string value. This makes it possible for scripts to clear variables if they can't unset them. .. versionchanged:: 2.0 Changed signature for parameter callback to also be passed the parameter. The old callback format will still work, but it will raise a warning to give you a chance to migrate the code easier. Z parameterNFTr') param_declsrNrhdefaultrnargsr`metavarrrdenvvarr autocompletionr.cs||p d| \|_|_|_t|||_|dkrH|jjrD|jj}nd}||_ ||_ ||_ ||_ | |_ ||_| |_||_| |_dk rddl}|jdtddtdttjdd fd d } | |_|jjr||jjkrtd |jjd |jd|dt|s|nd}|dk r|rNztt|d}Wn tk rLtddYnX|dkr|dk rz t|Wn0tk r|rd}nd}t|dYnX|dkrt||kr|rdnd}td|d|ddS)Nr5r rz'autocompletion' is renamed to 'shell_complete'. The old name is deprecated and will be removed in Click 8.1. See the docs about 'Parameter' for information about new behavior.rrrsrYr')r;rZr<r.csnddlm}g}|g|D]L}t|tr@||d|dd}nt|trR||}|j|r||q|S)Nrr&r r)rr'rLtuplerrrBrV)r;rZr<r'outrrr5r6r s     z*Parameter.__init__..shell_completez'nargs' must be z (or None) for type z , but it was .z1'default' must be a list when 'multiple' is true.zK'default' must be a list of lists when 'multiple' is true and 'nargs' != 1.z+'default' must be a list when 'nargs' != 1.z item lengthlengthz 'default' z must match nargs=) _parse_declsrEr;r<r convert_typerN is_compositearityrhrrr`rrrdrrrurvrwr8rr=r_custom_shell_completerbrnextrrrZ)rrrNrhrrrr`rrrdrr rru check_defaultrsubjectr5rr6rsx    zParameter.__init__rc Cs2|j|j|j|j|j|j|j|j|j |j d S)zGather information that could be useful for a tool generating user-facing documentation. Use :meth:`click.Context.to_info_dict` to traverse the entire CLI structure. .. versionadded:: 8.0 ) rEparam_type_namer;r<rNrhrr`rr) rErr;r<rNrrhrr`rrrr5r5r6rUs zParameter.to_info_dictcCsd|jjd|jdSrrrr5r5r6rkszParameter.__repr__declsrr.cCs tdSrTr)rrrr5r5r6rnszParameter._parse_declscCs|jS)zReturns the human readable name of this parameter. This is the same as the name for options, but the metavar for arguments. rrr5r5r6human_readable_namesszParameter.human_readable_namecCsF|jdk r|jS|j|}|dkr0|jj}|jdkrB|d7}|S)Nr ...)rrN get_metavarrErr)rrr5r5r6 make_metavarzs    zParameter.make_metavarrr;rr.cCsdSrTr5rr;rr5r5r6rszParameter.get_default.cCsdSrTr5rr5r5r6rscCsl|j|jdd}|dkr|j}t|r4|s.|S|}z|||WStk rf|jr`|YSYnXdS)aHGet the default for the parameter. Tries :meth:`Context.lookup_value` first, then the local default. :param ctx: Current context. :param call: If the default is a callable, call it. Disable to return the callable instead. .. versionchanged:: 8.0.1 Type casting can fail in resilient parsing mode. Invalid defaults will not prevent showing help text. .. versionchanged:: 8.0 Looks at ``ctx.default_map`` first. .. versionchanged:: 8.0 Added the ``call`` parameter. FrN)rrErrtype_cast_valuerr)rr;rrr5r5r6rsrDr;r.cCs tdSrTrrrDr;r5r5r6rCszParameter.add_to_parserr;r;r.cCsd||j}tj}|dkr*||}tj}|dkrD||j}tj}|dkr\||}tj }||fSrT) rrErnrtvalue_from_envvarrurrwrrvrr;r;rrr5r5r6 consume_values    zParameter.consume_value)r;rr.cs|dkr jsjdkrdSdStjtjdfdd jdksLjjr^tjdnDjdkrtjtjdfd d ntjtjdfd d jrt fd d |DS|S)zuConvert and validate a value against the option's :attr:`type`, :attr:`multiple`, and :attr:`nargs`. Nr5rcs8z t|WStk r2ttdddYnXdS)NzValue must be an iterable.r;rZ)rrrrrrr5r6 check_iters z-Parameter.type_cast_value..check_iterr )rZr;cstfdd|DS)Nc3s|]}|VqdSrTrNrxrr5r6rs=Parameter.type_cast_value..convert..)rrrr;rr5r6convertsz*Parameter.type_cast_value..convertcs\t|}t|jkrDttddt|jjt|ddtfdd|DS)Nz%Takes {nargs} values but 1 was given.z*Takes {nargs} values but {len} were given.)rrZrc3s|]}|VqdSrTrrrr5r6rsr)rrZrrrrLrrr5r6rs  c3s|]}|VqdSrTr5r)rr5r6r sz,Parameter.type_cast_value..) r`rr=rrrNrrrjrrr;rr5)rrr;rr6rs  zParameter.type_cast_valuercCs,|dkr dS|jdks|jr(|dkr(dSdS)NTr r5F)rr`)rrr5r5r6value_is_missing s zParameter.value_is_missingcCsL|dk r|||}|jr0||r0t||d|jdk rH||||}|S)Nr)rrhrrrrr5r5r6 process_value s   zParameter.process_valuercCsZ|jdkrdSt|jtr2tj|j}|rV|Sn$|jD]}tj|}|r8|Sq8dSrT)rrLrr3rrrr;rrr5r5r6resolve_envvar_value s     zParameter.resolve_envvar_valuecCs,||}|dk r(|jdkr(|j|}|Sr)rrrNsplit_envvar_valuerkr5r5r6r, s  zParameter.value_from_envvar)r;r;rr.c Cst||dV|||\}}||j|z|||}Wn tk r\|jsTd}YnXW5QRX|jrz||j|j<||fS)N)rZ) r\rrrEr Exceptionrrr)rr;r;rrrr5r5r6rY4 s zParameter.handle_parse_resultcCsdSrTr5rr5r5r6rUH szParameter.get_help_recordcCsgSrTr5rr5r5r6rK szParameter.get_usage_piecescCs"|jp |jg}ddd|DS)z{Get a stringified version of the param for use in error messages to indicate which param caused the error.  / css|]}d|dVqdS)'Nr5rr5r5r6rS sz+Parameter.get_error_hint..)r;rr)rr;Z hint_listr5r5r6get_error_hintN szParameter.get_error_hintr:csj|jdk rZ||||}|rHt|dtrHddlmfdd|D}ttjd|S|j |||S)aReturn a list of completions for the incomplete value. If a ``shell_complete`` function was given during init, it is used. Otherwise, the :attr:`type` :meth:`~click.types.ParamType.shell_complete` function is used. :param ctx: Invocation context for this command. :param incomplete: Value being completed. May be empty. .. versionadded:: 8.0 Nrr&csg|] }|qSr5r5rr&r5r6r,f sz,Parameter.shell_complete..r') rrLrrr'r=r>rrNr rr5r&r6r U s  zParameter.shell_complete) NNFNNNFNTFNNN)T).)T)-rOrorprqrr=rr rrr ParamTyperrkrr8rrrjrrrrrrrrrrrrrCMappingrnrrrrrrrYrUrrr r5r5r5r6rYsI , x    ( 2     cseZdZdZdZd&ejejee ej e efej e efe e eje ejej e e e ejej e j ej fejee e e ej ddfdd Zejeej fd fd d Zejee ejejeejeejefd d dZeeddddZeejejeefdddZejd'edejej dddZejd(ee ejej ej ejgej ffdddZd)ee ejej ej ejgej ffdfdd Zeej dddZeejedfdd Zeejej dd d!Zeejed"fejej e fd#fd$d% Z!Z"S)*r>a Options are usually optional values on the command line and have some extra features that arguments don't have. All other parameters are passed onwards to the parameter constructor. :param show_default: controls if the default value should be shown on the help page. Normally, defaults are not shown. If this value is a string, it shows the string instead of the value. This is particularly useful for dynamic options. :param show_envvar: controls if an environment variable should be shown on the help page. Normally, environment variables are not shown. :param prompt: if set to `True` or a non empty string then the user will be prompted for input. If set to `True` the prompt will be the option name capitalized. :param confirmation_prompt: Prompt a second time to confirm the value if it was prompted for. Can be set to a string instead of ``True`` to customize the message. :param prompt_required: If set to ``False``, the user will be prompted for input only when the option was specified as a flag without a value. :param hide_input: if this is `True` then the input on the prompt will be hidden from the user. This is useful for password input. :param is_flag: forces this option to act as a flag. The default is auto detection. :param flag_value: which value should be used for this flag if it's enabled. This is set to a boolean automatically if the option string contains a slash to mark two options. :param multiple: if this is set to `True` then the argument is accepted multiple times and recorded. This is similar to ``nargs`` in how it works but supports arbitrary number of arguments. :param count: this flag makes an option increment an integer. :param allow_from_autoenv: if this is enabled then the value of this parameter will be pulled from an environment variable in case a prefix is defined on the context. :param help: the help string. :param hidden: hide this option from help outputs. .. versionchanged:: 8.0.1 ``type`` is detected from ``flag_value`` if given. optionNFT)rrrconfirmation_promptprompt_required hide_inputrA flag_valuer`countallow_from_autoenvrNrrD show_choices show_envvarrer.c s&d|k}tj|f| | d||dkrP|jdkrrrrrrrDrrkr<rr rrNrArLZ BoolParamType is_bool_flagrrZIntRangerrrrrrr`)rrrrrrrrArr`rrrNrrDrrreZdefault_is_missingZ prompt_textr+r5r6r st       zOption.__init__rcs0t}|j|j|j|j|j|j|jd|S)N)rrrArrrD) r)rrrrrArrrD)rr-r+r5r6r s zOption.to_info_dictrc Cslg}g}d}g}|D]}|r6|dk r0td|}q|dddkrJdnd}||kr||d\} } | } | r|t| || | } | r|| | | krtd|dq|t|||q|dkr|r|jddd |d d d d  }|sd}|dkr@|s8d||fStd |sb|sbtd|d|d|||fS)NzName defined twicer /;zBoolean option z) cannot use the same flag for true/false.cSst|d S)Nrrzrr5r5r68 z%Option._parse_decls..rhrrrz#Could not determine name for optionz*No options defined but a name was passed (zH). Did you mean to declare an argument instead? Did you mean to pass '--z'?) isidentifierrr*r1rVrrrbsortrlower) rrrr;r<rEZpossible_namesdeclZ split_charfirstsecondr5r5r6r sN       zOption._parse_declsrcCs|jr d}n|jrd}nd}|jr|d}|jrj|jrj|j||j|j|dd|j||j|j|ddq|j||j|j||jdn|j||j|j||j ddS) NrVrstoreZ_constT)r|r;destactionconstF)r|r;rrr) r`rrArr< add_optionr;rErr)rrDr;rr5r5r6rCK sH  zOption.add_to_parserrcs\jr dSdtjttdfdd }|jg}jrL||jjpTd}g}jrވj }|dkrj r|j dk rj dk r|j dj }|dk rt|tr|nddd |D}|td j|d |j}d |_zj|dd } W5||_Xtjt} | s2| dk r҈js2|jr| rHdjd} ntt| ttfrnddd | D} nNt| rtd} n:jrjrtjrjnjdd} nt| } |tdj| dtjtjrj} | r|| jr|td|rDd|} |r8|d| dn d| d}rNdnd||fS)NF)r;r.cs6t|\}}|rdjs2js2|d7}|S)NTr)rrArr)r;rZ any_slashesZany_prefix_is_slashrr5r6 _write_optsx s   z+Option.get_help_record.._write_optsrrz, css|]}t|VqdSrTrrdr5r5r6r sz)Option.get_help_record..zenv var: {var})varTr()css|]}t|VqdSrTrrr5r5r6r sz (dynamic)rr zdefault: {default})rrhrz [][z; r) rDr=r rr;r<rVrrrrr}rErrLrrrLrrrrUrrrrrrNr Z_NumberRangeBaseZ_describe_rangerh)rr;rrrrrZvar_strZ resilient default_valueZshow_default_is_strZdefault_stringZ range_strZ extra_strr5rr6rUr s|        "zOption.get_help_recordrrcCsdSrTr5rr5r5r6r szOption.get_default.cCsdSrTr5rr5r5r6r scsJ|jr:|js:|jjD] }|j|jkr|jr|jSqdStj||dS)Nr) rArr@rrErrr)r)rr;rrZr+r5r6r s    c sTjdk st}jr*tj|Stj|jjjjfdddS)zThis is an alternative flow that can be activated in the full value processing if a value does not exist. It will prompt the user until a valid value exists and then returns the processed value as result. Ncs |SrT)rrrr5r6r rz)Option.prompt_for_value..)rrNrrrZ value_proc) rrrrrrNrrr)rr;rr5rr6prompt_for_value s   zOption.prompt_for_valuecsXt|}|dk r|S|jrT|jdk rT|jdk rT|jd|j}tj|}|S)Nr) r)rrr}rErr3rrrr+r5r6r s  zOption.resolve_envvar_valuecCs^||}|dkrdS|jdkt|j}|dkrZ|j|}|jrZ|jdkrZt||j}|Sr)rrrkr`rNrrX)rr;rZ value_depthr5r5r6r s   zOption.value_from_envvarrYrcst||\}}|tkrJ|jdk r<|js<||}tj}q|j}tj }n:|dtj hkr|jdk r|j sn|j r|js||}tj}||fSrT) r)rrrrrrnrxrrtrvrhrrr+r5r6r& s(   zOption.consume_value)NFFFTFNNFFTNNFTF)T).)T)#rOrorprqrr=rr rrkrrr rrrrrjrrrr8rCrUrrrrrrrrrnrrar5r5r+r6r>m s-   m  5' ^    r>cseZdZdZdZdejeeje ej ddfdd Z e eddd Z edd d Zejee ejejeejeejefd d dZeejedddZeedddZeeddddZZS)rgzArguments 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. ZargumentN)rrhrer.c st|dkr,|ddk rd}n|dddk}d|krrgr5r5r5r6s                                     ( H0A|* _Z