
    3jT                       % S SK Jr  S SKJr  S SKrS SKrS SKrS SK	J	r
  SSKJr  SSKJr  SSKJr  SSKJr  SS	KJr  SS
KJr  SSKJr  SSKJr              S)S jr " S S5      rSrSrSr " S S5      r " S S\5      r " S S\5      r " S S\5      r\R<                  " SSS9r\\\S.r S\!S '    S*     S+S! jjr"S,S" jr#S-S# jr$S.S$ jr%S/S% jr&S0S& jr'          S1S' jr(        S2S( jr)g)3    )annotationsN)gettext   )Argument)Command)Context)Group)Option)	Parameter)ParameterSource)echoc                   UR                  S5      u  pVn[        U5      nUc  gU" XX#5      nUS:X  a'  [        UR                  5       R	                  5       SS9  gUS:X  a(  [        UR                  5       R	                  5       5        gg)a  Perform shell completion for the given CLI program.

:param cli: Command being called.
:param ctx_args: Extra arguments to pass to
    ``cli.make_context``.
:param prog_name: Name of the executable in the shell.
:param complete_var: Name of the environment variable that holds
    the completion instruction.
:param instruction: Value of ``complete_var`` with the completion
    instruction and shell, in the form ``instruction_shell``.
:return: Status code to exit with.
_r   sourceF)nlr   complete)	partitionget_completion_classr   r   encoder   )	clictx_args	prog_namecomplete_varinstructionshellr   comp_clscomps	            P/home/wildlama/miniconda3/lib/python3.13/site-packages/click/shell_completion.pyshell_completer      s    & (11#6Ek#E*HC9;D hT[[]!!#.j T]]_##%&    c                  J    \ rS rSrSrSr  S         S	S jjrS
S jrSrg)CompletionItem:   a  Represents a completion value and metadata about the value. The
default metadata is ``type`` to indicate special shell handling,
and ``help`` if a shell supports showing a help string next to the
value.

Arbitrary parameters can be passed when creating the object, and
accessed using ``item.attr``. If an attribute wasn't passed,
accessing it returns ``None``.

:param value: The completion suggestion.
:param type: Tells the shell script to provide special completion
    support for the type. Click uses ``"dir"`` and ``"file"``.
:param help: String shown next to the value if supported.
:param kwargs: Arbitrary metadata. The built-in implementations
    don't use this, but custom type completions paired with custom
    shell support could use it.
valuetypehelp_infoNc                4    Xl         X l        X0l        X@l        g Nr$   )selfr%   r&   r'   kwargss        r   __init__CompletionItem.__init__O   s     "
	 $	
r    c                8    U R                   R                  U5      $ r*   )r(   get)r+   names     r   __getattr__CompletionItem.__getattr__[   s    zz~~d##r    )r(   r'   r&   r%   )plainN)
r%   t.Anyr&   strr'   
str | Noner,   r5   returnNone)r1   r6   r8   r5   )	__name__
__module____qualname____firstlineno____doc__	__slots__r-   r2   __static_attributes__ r    r   r"   r"   :   sP    $ 3I
 	

 
 	

 
 

$r    r"   a  %(complete_func)s() {
    local IFS=$'\n'
    local response

    response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD %(complete_var)s=bash_complete $1)

    for completion in $response; do
        IFS=',' read type value <<< "$completion"

        if [[ $type == 'dir' ]]; then
            COMPREPLY=()
            compopt -o dirnames
        elif [[ $type == 'file' ]]; then
            COMPREPLY=()
            compopt -o default
        elif [[ $type == 'plain' ]]; then
            COMPREPLY+=($value)
        fi
    done

    return 0
}

%(complete_func)s_setup() {
    complete -o nosort -F %(complete_func)s %(prog_name)s
}

%(complete_func)s_setup;
a  #compdef %(prog_name)s

%(complete_func)s() {
    local -a completions
    local -a completions_with_descriptions
    local -a response
    (( ! $+commands[%(prog_name)s] )) && return 1

    response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) %(complete_var)s=zsh_complete %(prog_name)s)}")

    for type key descr in ${response}; do
        if [[ "$type" == "plain" ]]; then
            if [[ "$descr" == "_" ]]; then
                completions+=("$key")
            else
                completions_with_descriptions+=("$key":"$descr")
            fi
        elif [[ "$type" == "dir" ]]; then
            _path_files -/
        elif [[ "$type" == "file" ]]; then
            _path_files -f
        fi
    done

    if [ -n "$completions_with_descriptions" ]; then
        _describe -V unsorted completions_with_descriptions -U
    fi

    if [ -n "$completions" ]; then
        compadd -U -V unsorted -a completions
    fi
}

if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
    # autoload from fpath, call function directly
    %(complete_func)s "$@"
else
    # eval/source/. command, register function for later
    compdef %(complete_func)s %(prog_name)s
fi
a  function %(complete_func)s;
    set -l response (env %(complete_var)s=fish_complete COMP_WORDS=(commandline -cp) COMP_CWORD=(commandline -t) %(prog_name)s);

    for completion in $response;
        set -l metadata (string split 
 $completion);

        if test $metadata[1] = "dir";
            __fish_complete_directories $metadata[2];
        else if test $metadata[1] = "file";
            __fish_complete_path $metadata[2];
        else if test $metadata[1] = "plain";
            if test $metadata[3] != "_";
                echo $metadata[2]	$metadata[3];
            else;
                echo $metadata[2];
            end;
        end;
    end;
end;

complete --no-files --command %(prog_name)s --arguments "(%(complete_func)s)";
c                      \ rS rSr% SrS\S'    S\S'              SS jr\SS j5       rSS jr	SS	 jr
SS
 jrSS jrSS jrSS jrSrg)ShellComplete   a  Base class for providing shell completion support. A subclass for
a given shell will override attributes and methods to implement the
completion instructions (``source`` and ``complete``).

:param cli: Command being called.
:param prog_name: Name of the executable in the shell.
:param complete_var: Name of the environment variable that holds
    the completion instruction.

.. versionadded:: 8.0
zt.ClassVar[str]r1   source_templatec                4    Xl         X l        X0l        X@l        g r*   )r   r   r   r   )r+   r   r   r   r   s        r   r-   ShellComplete.__init__   s      "(r    c                    [         R                  " SSU R                  R                  SS5      [         R                  S9nSU S3$ )zAThe name of the shell function defined by the completion
script.
z\W* -r   )flags_completion)resubr   replaceASCII)r+   	safe_names     r   	func_nameShellComplete.func_name   s<    
 FF62t~~'='=c3'GrxxX	9+[))r    c                J    U R                   U R                  U R                  S.$ )zVars for formatting :attr:`source_template`.

By default this provides ``complete_func``, ``complete_var``,
and ``prog_name``.
)complete_funcr   r   )rR   r   r   r+   s    r   source_varsShellComplete.source_vars   s%     "^^ --
 	
r    c                <    U R                   U R                  5       -  $ )zProduce the shell script that defines the completion
function. By default this ``%``-style formats
:attr:`source_template` with the dict returned by
:meth:`source_vars`.
)rE   rW   rV   s    r   r   ShellComplete.source  s     ##d&6&6&888r    c                    [         e)zUse the env vars defined by the shell script to return a
tuple of ``args, incomplete``. This must be implemented by
subclasses.
NotImplementedErrorrV   s    r   get_completion_args!ShellComplete.get_completion_args  s
    
 "!r    c                    [        U R                  U R                  U R                  U5      n[	        X1U5      u  pBUR                  X25      $ )a,  Determine the context and last complete command or parameter
from the complete args. Call that object's ``shell_complete``
method to get the completions for the incomplete value.

:param args: List of complete args before the incomplete value.
:param incomplete: Value being completed. May be empty.
)_resolve_contextr   r   r   _resolve_incompleter   )r+   args
incompletectxobjs        r   get_completionsShellComplete.get_completions  s?     txxM-cD!!#22r    c                    [         e)zFormat a completion item into the form recognized by the
shell script. This must be implemented by subclasses.

:param item: Completion item to format.
r\   r+   items     r   format_completionShellComplete.format_completion   s
     "!r    c                    U R                  5       u  pU R                  X5      nU Vs/ s H  o@R                  U5      PM     nnSR                  U5      $ s  snf )zProduce the completion data to send back to the shell.

By default this calls :meth:`get_completion_args`, gets the
completions, then calls :meth:`format_completion` for each
completion.

)r^   rg   rl   join)r+   rc   rd   completionsrk   outs         r   r   ShellComplete.complete(  sV      335**4<8CD%%d+Dyy~ Es   A)r   r   r   r   N)
r   r   r   cabc.MutableMapping[str, t.Any]r   r6   r   r6   r8   r9   r8   r6   )r8   zdict[str, t.Any]r8   ztuple[list[str], str])rc   	list[str]rd   r6   r8   zlist[CompletionItem]rk   r"   r8   r6   )r:   r;   r<   r=   r>   __annotations__r-   propertyrR   rW   r   r^   rg   rl   r   r@   rA   r    r   rC   rC      s    
 
 %$
)
) 2
) 	
)
 
) 

) * *

9"
3"
r    rC   c                  `   ^  \ rS rSrSrSr\r\S	S j5       r	S
U 4S jjr
SS jrSS jrSrU =r$ )BashCompletei5  zShell completion for Bash.bashc                 |   SS K n SS KnU R                  S5      nUc  S nOMUR                  USSS/UR                  S9n[
        R                  " SUR                  R                  5       5      nUb:  UR                  5       u  pVUS:  d  US:X  a  US:  a  [        [        S	5      S
S9  g g g [        [        S5      S
S9  g )Nr   r}   z--norcz-czecho "${BASH_VERSION}")stdoutz^(\d+)\.(\d+)\.\d+4zCShell completion is not supported for Bash versions older than 4.4.T)errz@Couldn't detect Bash version, shell completion is not supported.)shutil
subprocesswhichrunPIPErM   searchr   decodegroupsr   r   )r   r   bash_exematchoutputmajorminors          r   _check_versionBashComplete._check_version;  s    <<'E^^8T+CD! $ F II3V]]5I5I5KLE <<>LEs{eslus{4  0;l TUr    c                @   > U R                  5         [        TU ]	  5       $ r*   )r   superr   )r+   	__class__s    r   r   BashComplete.source\  s    w~r    c                    [        [        R                  S   5      n[        [        R                  S   5      nUSU n X   nX44$ ! [         a    Sn X44$ f = fN
COMP_WORDS
COMP_CWORDr   rI   split_arg_stringosenvironint
IndexErrorr+   cwordscwordrc   rd   s        r   r^    BashComplete.get_completion_args`  i    !"**\":;BJJ|,-a	J   	J	   A AAc                8    UR                    SUR                   3$ )N,)r&   r%   rj   s     r   rl   BashComplete.format_completionl  s    ))Adjj\**r    rA   )r8   r9   ru   rv   rx   )r:   r;   r<   r=   r>   r1   _SOURCE_BASHrE   staticmethodr   r   r^   rl   r@   __classcell__)r   s   @r   r|   r|   5  s7    $D"O @ 
 + +r    r|   c                  4    \ rS rSrSrSr\rSS jrS	S jr	Sr
g)
ZshCompleteip  zShell completion for Zsh.zshc                    [        [        R                  S   5      n[        [        R                  S   5      nUSU n X   nX44$ ! [         a    Sn X44$ f = fr   r   r   s        r   r^   ZshComplete.get_completion_argsv  r   r   c                    UR                   =(       d    SnUS:w  a  UR                  R                  SS5      OUR                  nUR                   SU SU 3$ )Nr   :z\:ro   r'   r%   rO   r&   )r+   rk   help_r%   s       r   rl   ZshComplete.format_completion  sO    		 S 383,

""3.DJJ))BugRw//r    rA   Nrv   rx   )r:   r;   r<   r=   r>   r1   _SOURCE_ZSHrE   r^   rl   r@   rA   r    r   r   r   p  s    #D!O
 0r    r   c                  4    \ rS rSrSrSr\rSS jrS	S jr	Sr
g)
FishCompletei  zShell completion for Fish.fishc                    [        [        R                  S   5      n[        R                  S   nU(       a  [        U5      S   nUSS  nU(       a   U(       a  US   U:X  a  UR                  5         X24$ )Nr   r   r   r   )r   r   r   pop)r+   r   rd   rc   s       r   r^    FishComplete.get_completion_args  sd    !"**\":;ZZ-
)*5a8Jabz $48z#9HHJr    c                    UR                   =(       d    SnUR                  R                  SS5      nUR                  SS5      nUR                   SU SU 3$ )z|
.. versionchanged:: 8.4.0
    Escape newlines in value and help to fix completion errors with
    multi-line help strings.
r   ro   z\nr   )r+   rk   r   r%   help_escapeds        r   rl   FishComplete.format_completion  sS     		 S

""4/}}T51))BugR~66r    rA   Nrv   rx   )r:   r;   r<   r=   r>   r1   _SOURCE_FISHrE   r^   rl   r@   rA   r    r   r   r     s    $D"O 7r    r   ShellCompleteTypeztype[ShellComplete])bound)r}   r   r   zdict[str, type[ShellComplete]]_available_shellsc                6    Uc  U R                   nU [        U'   U $ )aQ  Register a :class:`ShellComplete` subclass under the given name.
The name will be provided by the completion instruction environment
variable during completion.

:param cls: The completion class that will handle completion for the
    shell.
:param name: Name to register the class under. Defaults to the
    class's ``name`` attribute.
)r1   r   )clsr1   s     r   add_completion_classr     s"     |xx!dJr    c                ,    [         R                  U 5      $ )zLook up a registered :class:`ShellComplete` subclass by the name
provided by the completion instruction environment variable. If the
name isn't registered, returns ``None``.

:param shell: Name the class is registered under.
)r   r0   )r   s    r   r   r     s       ''r    c                    SSK nUR                  U SS9nSUl        SUl        / n U H  nUR                  U5        M     U$ ! [         a    UR                  UR
                  5         U$ f = f)a  Split an argument string as with :func:`shlex.split`, but don't
fail if the string is incomplete. Ignores a missing closing quote or
incomplete escape sequence and uses the partial token as-is.

.. code-block:: python

    split_arg_string("example 'my file")
    ["example", "my file"]

    split_arg_string("example my\")
    ["example", "my"]

:param string: String to split.

.. versionchanged:: 8.2
    Moved to ``shell_completion`` from ``parser``.
r   NT)posixrI   )shlexwhitespace_split
commentersappend
ValueErrortoken)stringr   lexrr   r   s        r   r   r     sw    $ 
++fD+
)CCCN
CEJJu  J   	

399Js   A %A+*A+c                   [        U[        5      (       d  gU R                  R                  UR                  5      nUR
                  S:H  =(       d}    U R                  UR                  5      [        R                  L=(       dK    UR
                  S:  =(       a5    [        U[        [        45      =(       a    [        U5      UR
                  :  $ )zDetermine if the given parameter is an argument that can still
accept values.

:param ctx: Invocation context for the command represented by the
    parsed complete args.
:param param: Argument object being checked.
Fr   r   )
isinstancer   paramsr0   r1   nargsget_parameter_sourcer   COMMANDLINEtuplelistlen)re   paramr%   s      r   _is_incomplete_argumentr     s     eX&&JJNN5::&Er 	
##EJJ/7R7RR	
 KK!O )55$-0)E
U[[(r    c                8    U(       d  gUS   nX R                   ;   $ )z5Check if the value looks like the start of an option.Fr   )_opt_prefixes)re   r%   cs      r   _start_of_optionr     s     aA!!!!r    c                6   [        U[        5      (       d  gUR                  (       d  UR                  (       a  gSn[	        [        U5      5       H.  u  pEUS-   UR                  :  a    O[        X5      (       d  M,  Un  O   USL=(       a    X2R                  ;   $ )zDetermine if the given parameter is an option that needs a value.

:param args: List of complete args before the incomplete value.
:param param: Option object being checked.
FNr   )	r   r
   is_flagcount	enumeratereversedr   r   opts)re   rc   r   last_optionindexargs         r   _is_incomplete_optionr   &  s}     eV$$}}K/
19u{{"C%%K 0 d"@{jj'@@r    c           
     0   SUS'   U R                   " X#R                  5       40 UD6 nUR                  UR                  -   nU(       Ga  UR                  n[        U[        5      (       a  UR                  (       dX  UR                  XC5      u  pgnUc  UsSSS5        $ UR                  XcUSS9 nUnUR                  UR                  -   nSSS5        O}UnU(       aV  UR                  XC5      u  pgnUc  UsSSS5        $ UR                  UUUSSSS9 n	U	nUR                  nSSS5        U(       a  MV  Un/ UR                  QUR                  QnOO
U(       a  GM  SSS5        U$ ! , (       d  f       N"= f! , (       d  f       NZ= f! , (       d  f       W$ = f)aH  Produce the context hierarchy starting with the command and
traversing the complete arguments. This only follows the commands,
it doesn't trigger input prompts or callbacks.

:param cli: Command being called.
:param prog_name: Name of the executable in the shell.
:param args: List of complete args before the incomplete value.
Tresilient_parsingN)parentr   F)r   allow_extra_argsallow_interspersed_argsr   )	make_contextcopy_protected_argsrc   commandr   r	   chainresolve_command)
r   r   r   rc   re   r   r1   cmdsub_ctxsub_sub_ctxs
             r   ra   ra   ?  s    %)H !			)YY[	=H	=""SXX-kkG'5))}}&-&=&=c&HODt{" 
>	= ))3$ *  %"22SXX=	  "G*1*A*A#*L4;#&3 
>	=6 !--  #&-149.2 .  )&1G#*<<D $" "CDW44Dw||DDM d 
>V J=  7 
>	=V JsN   A,FF.E$
*F>FE5!F2%F$
E2	.F5
F	?F
Fc                   US:X  a  SnO;SU;   a5  [        X5      (       a%  UR                  S5      u  p4nUR                  U5        SU;  a  [        X5      (       a  U R                  U4$ U R                  R	                  U 5      nU H  n[        XU5      (       d  M  Xb4s  $    U H  n[        X5      (       d  M  Xb4s  $    U R                  U4$ )aP  Find the Click object that will handle the completion of the
incomplete value. Return the object and the incomplete value.

:param ctx: Invocation context for the command represented by
    the parsed complete args.
:param args: List of complete args before the incomplete value.
:param incomplete: Value being completed. May be empty.
=rI   z--)r   r   r   r   
get_paramsr   r   )re   rc   rd   r1   r   r   r   s          r   rb   rb   |  s     S
	
	/@@(2237D 4,S=={{J&&[[##C(F  E22$$  "3..$$  ;;
""r    )r   r   r   rt   r   r6   r   r6   r   r6   r8   r   r*   )r   r   r1   r7   r8   r   )r   r6   r8   ztype[ShellComplete] | None)r   r6   r8   rw   )re   r   r   r   r8   bool)re   r   r%   r6   r8   r   )re   r   rc   rw   r   r   r8   r   )
r   r   r   rt   r   r6   rc   rw   r8   r   )re   r   rc   rw   rd   r6   r8   ztuple[Command | Parameter, str])*
__future__r   collections.abcabccabcr   rM   typingtr   r   corer   r   r   r	   r
   r   r   utilsr   r   r"   r   r   r   rC   r|   r   r   TypeVarr   r   ry   r   r   r   r   r   r   ra   rb   rA   r    r   <module>r     s   "  	 	          ! $	$-$ $ 	$
 $ 	$N"$ "$LL*X6e eP8+= 8+v!0- !0H"7= "7J II19NO  5 1  04	",(("J."A2:	:-: : 	:
 :z,#	,#!,#/2,#$,#r    