jfH hUddlZddlZddlZddlmZddlmZddlmZddlm Z ddlm Z ddlm Z dd lm Z dd lm Z dd lmZdd lmZd edejeejfdedededef dZGddZdZdZdZGddZGddeZGddeZGdd eZejd!ej e"Z!eeed#Z"ej#eej efe$d$< d4d%e!d&ej%ede!fd'Z&d(edej%ej efd)Z'd*e d+e de(fd,Z)d*e d-ede(fd.Z*d*e d/ej+ed+e de(fd0Z,d edejeejfded/ej+ede f d1Z-d*e d/ej+ed2edej.ej/ee feffd3Z0dS)5N)gettext)Argument) BaseCommand)Context) MultiCommand)Option) Parameter)ParameterSource)split_arg_string)echoclictx_args prog_name complete_var instructionreturnc|d\}}}t|}|dS|||||}|dkr#t|dS|dkr#t|dSdS)aPerform 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. _Nrsourcercomplete) partitionget_completion_classr rr) rrrrrshellrcomp_clscomps v/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/click/shell_completion.pyshell_completers&(11#66E1k#E**Hq 8C9l ; ;Dh T[[]]qj   T]]__q 1c |eZdZdZdZ d dejdedejedejd df d Z d ed ejfd Z dS)CompletionItema)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. valuetypehelp_infoplainNr#r$r%kwargsrc >||_||_||_||_dSNr")selfr#r$r%r(s r__init__zCompletionItem.__init__Ls$"  %)  rnamec6|j|Sr*)r&get)r+r-s r __getattr__zCompletionItem.__getattr__Xsz~~d###r)r'N) __name__ __module__ __qualname____doc__ __slots__tAnystrOptionalr,r0rrr!r!7s$3I  $  u  jo  %      $$$$$$$$rr!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 affunction %(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"; echo $metadata[2]; end; end; end; complete --no-files --command %(prog_name)s --arguments "(%(complete_func)s)"; c eZdZUdZejeed< ejeed< dedej eej fdededd f d Z e defd Z dejeej ffd Zdefd ZdejejeeffdZdejededejefdZdedefdZdefdZd S) ShellCompleteaBase 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 r-source_templaterrrrrNc>||_||_||_||_dSr*)rrrr)r+rrrrs rr,zShellComplete.__init__s'  "(rctjdd|jddtj}d|dS)zQThe name of the shell function defined by the completion script. z\W*-r)flags _completion)resubrreplaceASCII)r+ safe_names r func_namezShellComplete.func_namesA F62t~'='=c3'G'GrxXXX )9))))rc,|j|j|jdS)zVars for formatting :attr:`source_template`. By default this provides ``complete_func``, ``complete_var``, and ``prog_name``. ) complete_funcrr)rIrrr+s r source_varszShellComplete.source_varss#"^ -   rc:|j|zS)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`. )r=rMrLs rrzShellComplete.sources #d&6&6&8&888rct)zUse the env vars defined by the shell script to return a tuple of ``args, incomplete``. This must be implemented by subclasses. NotImplementedErrorrLs rget_completion_argsz!ShellComplete.get_completion_argss "!rargs incompletect|j|j|j|}t |||\}}|||S)aTDetermine 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_contextrrr_resolve_incompleter)r+rSrTctxobjs rget_completionszShellComplete.get_completionssHtxMM-c4DDZ!!#z222ritemct)zFormat a completion item into the form recognized by the shell script. This must be implemented by subclasses. :param item: Completion item to format. rPr+r[s rformat_completionzShellComplete.format_completions "!rc\}}||}fd|D}d|S)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. c:g|]}|Sr:)r^).0r[r+s r z*ShellComplete.complete..&s'DDDt%%d++DDDr )rRrZjoin)r+rSrT completionsouts` rrzShellComplete.completesY 3355j**4<< DDDD DDDyy~~r)r1r2r3r4r6ClassVarr8__annotations__rMutableMappingr7r,propertyrIDictrMrTupleListrRr!rZr^rr:rrr<r<s   *S/ Z_$$$ )  )"3:. ) )  )  ) ) ) )*3***X*  QVCJ/     99999"QWQVC[#-=%>"""" 3F3K 3-0 3   3 3 3 3"n""""" #      rr<ceZdZdZdZeZed dZde ffd Z de j e j e e ffdZdede fd ZxZS) BashCompletezShell completion for Bash.bashrNc|ddl}|gd|j}tjd|j}|M|\}}|dks |dkr&|dkr"ttdddSdSdSttd ddS) Nr)rpz-czecho "${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.) subprocessrunPIPErDsearchrrdecodegroupsr r)ruoutputmatchmajorminors r_check_versionzBashComplete._check_version0s 4 4 4Z_    /1E1E1G1GHH   <<>>LE5s{{esllus{{4 +l{{ TUU      rcl|tSr*)rsuperr)r+ __class__s rrzBashComplete.sourceJs) ww~~rcttjd}ttjd}|d|} ||}n#t$rd}YnwxYw||fSN COMP_WORDS COMP_CWORDrr@r osenvironint IndexErrorr+cwordscwordrSrTs rrRz BashComplete.get_completion_argsNx!"*\":;;BJ|,--ag JJ   JJJ Z A A"!A"r[c$|jd|jS)N,)r$r#r]s rr^zBashComplete.format_completionZs)**dj***r)rN)r1r2r3r4r- _SOURCE_BASHr= staticmethodrr8rr6rlrmrRr!r^ __classcell__)rs@rroro*s$$ D"O\2         QWQVC[#-=%>     +n+++++++++rrocfeZdZdZdZeZdejej e e ffdZ de de fdZ dS) ZshCompletezShell completion for Zsh.zshrcttjd}ttjd}|d|} ||}n#t$rd}YnwxYw||fSrrrs rrRzZshComplete.get_completion_argsdrrr[cF|jd|jd|jr|jndS)Nrcr)r$r#r%r]s rr^zZshComplete.format_completionps/)NNtzNN$)-LTYYNNNrN)r1r2r3r4r- _SOURCE_ZSHr=r6rlrmr8rRr!r^r:rrrr^s{## D!O  QWQVC[#-=%>     OnOOOOOOOrrcfeZdZdZdZeZdejej e e ffdZ de de fdZ dS) FishCompletezShell completion for Fish.fishrcttjd}tjd}|dd}|r"|r |d|kr|||fS)Nrrr)r rrpop)r+rrTrSs rrRz FishComplete.get_completion_argszsf!"*\":;;Z - abbz  $ 48z#9#9 HHJJJZrr[cd|jr|jd|jd|jS|jd|jS)Nr )r%r$r#r]s rr^zFishComplete.format_completionsF 9 <i;;$*;; ;; ;)**dj***rN)r1r2r3r4r- _SOURCE_FISHr=r6rlrmr8rRr!r^r:rrrrtss$$ D"O  QWQVC[#-=%>     +n+++++++rrShellCompleteType)bound)rprr_available_shellsclsr-c,||j}|t|<|S)amRegister 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. )r-r)rr-s radd_completion_classrs  |x!d Jrrc6t|S)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. )rr/)rs rrrs   ' ''rrXparamc`t|tsdS|jJ|j|j}|jdkpd||jtjup>|jdko3t|ttfot||jkS)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. FNrr) isinstancerr-paramsr/nargsget_parameter_sourcer COMMANDLINEtuplelistlen)rXrr#s r_is_incomplete_argumentrs eX & &u : ! ! ! JNN5: & &E r  # #EJ / /7R R  K!O )55$-00 )E U[( rr#c,|sdS|d}||jvS)z5Check if the value looks like the start of an option.Fr) _opt_prefixes)rXr#cs r_start_of_optionrs& u aA ! !!rrSct|tsdS|js|jrdSd}t t |D]'\}}|dz|jkrnt||r|}(|duo||jvS)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) rr is_flagcount enumeratereversedrropts)rXrSr last_optionindexargs r_is_incomplete_optionrs eV $ $u } uK// s 19u{ " " E C % % K d " @{ej'@@rcd|d<|j||fi|}|j|jz}|r|j}t |t r|jsG|||\}}}||S||||d}|j|jz}nZ|}|rB|||\}}}||S||||ddd}|j}|B|}g|j|j}nn||S)a`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. Tresilient_parsingN)parentrF)rallow_extra_argsallow_interspersed_argsr) make_contextcopyprotected_argsrScommandrrchainresolve_command) rrrrSrXrr-cmdsub_ctxs rrVrVse%)H ! # 9diikk > >X > >C   (D "+ g| , , = @")"9"9#t"D"Dc4;J&&tT#QU&VV)CH4(&-&=&=c4&H&HOD#t{" !..")-05*. /G#t||r.|d\}}}||d|vrt||r |j|fS|j|}|D]}t |||r||fcS|D]}t ||r||fcS|j|fS)ahFind 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. =r@z--)rrappendr get_paramsrr)rXrSrTr-rrrs rrWrW(sS  /Z@@ (22377a D  4,S*=={J&& [ # #C ( (F%% dE 2 2 %*$ $ $ $ % %% "3 . . %*$ $ $ $ % ; ""rr*)1rrDtypingr6rrcorerrrrr r r parserr utilsr rir8r7rrr!rrrr<rorrTypeVarTyperrrkrhr9rrboolrrrmrrVrlUnionrWr:rrrs9  !!!!!!$$$$$$# # sAEz*# #  #  #  # # # # L"$"$"$"$"$"$"$"$L @* X .ggggggggT1+1+1+1+1+=1+1+1+hOOOOO-OOO,+++++=+++2AI1 9NOOO   9916#qvm44559 "#*S/((( 16-3H(I((((t2"'"#"$""""AwAafSkA)APTAAAA06 6sAEz*66 &+ 6  6666r,# ,#s ,#14,#WQW[)+ ,c 12,#,#,#,#,#,#r