
    wdf0                        d dl Z d dlZd dlZddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
 ddlmZ 	 d d	lmZ n# e$ r d dlZY nw xY wd
ZdZdZdZeeedZ ej        d          Zd Zd Zd Zd Zd Zd Zd Zd Zd Zd Z d Z!d Z"dS )    N   )Argument)MultiCommand)Option)split_arg_string)Choice)echo)abc=a  
%(complete_func)s() {
    local IFS=$'
'
    COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \
                   COMP_CWORD=$COMP_CWORD \
                   %(autocomplete_var)s=complete $1 ) )
    return 0
}

%(complete_func)setup() {
    local COMPLETION_OPTIONS=""
    local BASH_VERSION_ARR=(${BASH_VERSION//./ })
    # Only BASH version 4.4 and later have the nosort option.
    if [ ${BASH_VERSION_ARR[0]} -gt 4 ] || ([ ${BASH_VERSION_ARR[0]} -eq 4 ] && [ ${BASH_VERSION_ARR[1]} -ge 4 ]); then
        COMPLETION_OPTIONS="-o nosort"
    fi

    complete $COMPLETION_OPTIONS -F %(complete_func)s %(script_names)s
}

%(complete_func)setup
a  
#compdef %(script_names)s

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

    response=("${(@f)$( env COMP_WORDS="${words[*]}" \
                        COMP_CWORD=$((CURRENT-1)) \
                        %(autocomplete_var)s="complete_zsh" \
                        %(script_names)s )}")

    for key descr in ${(kv)response}; do
      if [[ "$descr" == "_" ]]; then
          completions+=("$key")
      else
          completions_with_descriptions+=("$key":"$descr")
      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
    compstate[insert]="automenu"
}

compdef %(complete_func)s %(script_names)s
zcomplete --no-files --command %(script_names)s --arguments "(env %(autocomplete_var)s=complete_fish COMP_WORDS=(commandline -cp) COMP_CWORD=(commandline -t) %(script_names)s)")bashzshfishz[^a-zA-Z0-9_]c                    t                               d|                     dd                    }t                              |t
                    }|d                    |          | |dz                                  dz   S )N -_z_{}_completion)complete_funcscript_namesautocomplete_var;)_invalid_ident_char_resubreplace_completion_scriptsgetCOMPLETION_SCRIPT_BASHformatstrip)	prog_namecomplete_varshellcf_namescripts        X/var/www/book.euthymeo.com/html/venv/lib/python3.11/site-packages/click/_bashcomplete.pyget_completion_scriptr%   _   s}    $((Y->->sC-H-HIIG $$U,BCCF-44W==% ,
 
	
 egg     c                    |                      ||d          }|j        |j        z   }|rt          |j        t
                    r|j        j        sL|j                            ||          \  }}}||S |                     |||d          }|j        |j        z   }n\|rG|j                            ||          \  }}}||S |                     |||ddd          }|j        }|G|}|j        |j        z   }nn||S )a  Parse into a hierarchy of contexts. Contexts are connected
    through the parent variable.

    :param cli: command definition
    :param prog_name: the program that is running
    :param args: full list of args
    :return: the final context/command parsed
    T)resilient_parsingN)parentr(   F)r)   allow_extra_argsallow_interspersed_argsr(   )make_contextprotected_argsargs
isinstancecommandr   chainresolve_command)clir   r.   ctxcmd_namecmdsub_ctxs          r$   resolve_ctxr8   l   sQ    

9dd

C
CC(D
 ck<00 	;$ =&)k&A&A#t&L&L##t;J&&d3$ '   )CH4  (*-+*E*Ec4*P*P'Hc4{"
!.. ")-05*. /  G #<D  ( -<9  : Jr&   c                 "    | o| dd         dk    S )z
    :param param_str: param_str to check
    :return: whether or not this is the start of an option declaration
        (i.e. starts "-" or "--")
    Nr   r    )	param_strs    r$   start_of_optionr<      s     -2A2#--r&   c                     t          |t                    sdS |j        rdS d}t          t	          d | D                                 D ]&\  }}|dz   |j        k    r nt          |          r|}'|r||j        v rdndS )aU  
    :param all_args: the full original list of args supplied
    :param cmd_param: the current command paramter
    :return: whether or not the last option declaration (i.e. starts
        "-" or "--") is incomplete and corresponds to this cmd_param. In
        other words whether this cmd_param option can still accept
        values
    FNc                 (    g | ]}|t           k    |S r:   )	WORDBREAK).0args     r$   
<listcomp>z(is_incomplete_option.<locals>.<listcomp>   s"    >>>#SI-=-=#-=-=-=r&   r   T)r/   r   is_flag	enumeratereversednargsr<   opts)all_args	cmd_paramlast_optionindexarg_strs        r$   is_incomplete_optionrM      s     i(( u uK#>>>>>??  " "w 19y&&E7## 	"!KK;).#@#@44eKr&   c                     t          |t                    sdS | |j                 }|dS |j        dk    rdS t          |t          j                  r%|j        dk    rt          |          |j        k     rdS dS )a`  
    :param current_params: the current params and values for this
        argument as already entered
    :param cmd_param: the current command parameter
    :return: whether or not the last argument is incomplete and
        corresponds to this cmd_param. In other words whether or not the
        this cmd_param argument can still accept values
    FNTr   )r/   r   namerF   r
   Iterablelen)current_paramsrI   current_param_valuess      r$   is_incomplete_argumentrU      s     i** u)).9#t"t'66Oa$%%	77t5r&   c                     g }t          |j        t                    rfd|j        j        D             }n+|j        $|                    | |          }d |D             }|S )a  
    :param ctx: context associated with the parsed command
    :param args: full list of args
    :param incomplete: the incomplete text to autocomplete
    :param cmd_param: command definition
    :return: all the possible user-specified completions for the param
    c                 \    g | ](}t          |                                        $|d f)S N)str
startswith)r@   c
incompletes     r$   rB   z,get_user_autocompletions.<locals>.<listcomp>   sF     
 
 
Q9J9J:9V9V
I
 
 
r&   N)r4   r.   r\   c                 D    g | ]}t          |t                    r|n|d fS rX   )r/   tupler@   r[   s     r$   rB   z,get_user_autocompletions.<locals>.<listcomp>   s<     
 
 
9:Au%%4AAAt9
 
 
r&   )r/   typer   choicesautocompletion)r4   r.   r\   rI   resultsdynamic_completionss     `   r$   get_user_autocompletionsre      s     G).&)) 

 
 
 
(~5
 
 
 
	!	-'66$: 7 
 

 
>Q
 
 
 Nr&   c              #      K   | j                             |           D ]=}|                    |          r&| j                             | |          }|j        s|V  >dS )z
    :param ctx: context associated with the parsed command
    :starts_with: string that visible commands must start with.
    :return: all visible (not hidden) commands that start with starts_with.
    N)r0   list_commandsrZ   get_commandhidden)r4   starts_withr[   r0   s       r$   "get_visible_commands_starting_withrk      sp       [&&s++  <<$$ 	k--c155G> 	 r&   c                     t           j        t                    r-|                    d t	           |          D                         j        q j         t           j        t                    rG j        j        r; fdt	           |          D             }|                    d |D                         j        od S d S )Nc                 D    g | ]}|j         |                                fS r:   rP   get_short_help_strr_   s     r$   rB   z.add_subcommand_completions.<locals>.<listcomp>   s;        --//0  r&   c                 0    g | ]}|j         j        v|S r:   )rP   r-   )r@   r[   r4   s     r$   rB   z.add_subcommand_completions.<locals>.<listcomp>  s3     " " "6!333 333r&   c                 D    g | ]}|j         |                                fS r:   rn   r_   s     r$   rB   z.add_subcommand_completions.<locals>.<listcomp>  s+    NNNa!&!..001NNNr&   )r/   r0   r   extendrk   r)   r1   )r4   r\   completions_outremaining_commandss   `   r$   add_subcommand_completionsru      s    #+|,, 
 ;CLL  	
 	
 	
 *
 jck<00 	S[5F 	" " " ";CLL" " "
 ""NN;MNNN   *
 
 
 
 
 r&   c                 :  	
 t          j        |          	t          | ||          }|g S d	v }t                    rGt          v r>                    t                    }	                    |d                    |d         nt          k    rdg }|szt                    rk|j        j        D ]\
t          
t                    rE
j        s>	
fd
j        
j        z   D             }|                    
fd|D                        ]|S |j        j        D ]&
t          	
          rt!          |	
          c S '|j        j        D ]+
t#          |j        
          rt!          |	
          c S ,t%          ||           t'          |          S )z
    :param cli: command definition
    :param prog_name: the program that is running
    :param args: full list of args
    :param incomplete: the incomplete text to autocomplete
    :return: all the possible completions for the incomplete
    Nz--r      r   c                 *    g | ]}|vsj         |S r:   )multiple)r@   	param_optrH   params     r$   rB   zget_choices.<locals>.<listcomp>.  s5       ! 00EN0 000r&   c                 L    g | ] }|                               |j        f!S r:   )rZ   help)r@   or\   r{   s     r$   rB   zget_choices.<locals>.<listcomp>4  s0    UUUALL<T<TUa_UUUr&   )copydeepcopyr8   r<   r?   	partitionappendr0   paramsr/   r   ri   rG   secondary_optsrr   rM   re   rU   ru   sorted)r3   r   r.   r\   r4   has_double_dashpartition_incompletecompletions
param_optsrH   r{   s      `     @@r$   get_choicesr     s    }T""H
c9d
+
+C
{	h&O z"" yJ'>'>)33I>>,Q/000)!,

	y	 	 
K z:: [' 		 		E%((      %*Z%2F%F  

 ""UUUUUjUUU   # N N%00 	N+C:uMMMMM	N # N N!#*e44 	N+C:uMMMMM	N sJ<<<+r&   c                 d   t          t          j        d                   }t          t          j        d                   }|d|         }	 ||         }n# t          $ r d}Y nw xY wt          | |||          D ]8}t          |d                    |rt          |d         r|d         nd           9dS )N
COMP_WORDS
COMP_CWORDr   r   r   r   T)r   osenvironint
IndexErrorr   r	   )r3   r   include_descriptionscwordscwordr.   r\   items           r$   do_completer   E  s    bj677F
<())E!E'?DE]

   


 CD*== . .T!W 	. DG,a---4s   
A A"!A"c                 B   t          t          j        d                   }t          j        d         }|dd          }t          | |||          D ]P}|d         r1t	          d                    |d         |d                              ;t	          |d                    QdS )Nr   r   r   z{arg}	{desc}r   )rA   descT)r   r   r   r   r	   r   )r3   r   r   r\   r.   r   s         r$   do_complete_fishr   Y  s    bj677FL)J!"":DCD*==  7 	''DG$q''BBCCCCaMMMM4r&   c                     d|v r|                     dd          \  }}n|}d}|dk    r t          t          |||                     dS |dk    r/|dk    rt          | |          S |dv rt	          | ||d	k              S d
S )Nr   r   r   sourceTcompleter   >   r   r   r   F)splitr	   r%   r   r   )r3   r   r    complete_instrr0   r!   s         r$   bashcompleter   g  s    
n'--c155 ("9lEBBCCCt	J		F??#C333o%%sIu~>>>5r&   )#r   r   recorer   r   r   parserr   typesr   utilsr	   collectionsr
   ImportErrorr?   r   COMPLETION_SCRIPT_ZSHCOMPLETION_SCRIPT_FISHr   compiler   r%   r8   r<   rM   rU   re   rk   ru   r   r   r   r   r:   r&   r$   <module>r      s    				 				                   $ $ $ $ $ $                	 0! H  # "   $$455 
 
 
( ( (V. . .L L L2  2  0
 
 
  22 2 2j  (      s   9 	AA