File: //lib/python3/dist-packages/click/__pycache__/_bashcomplete.cpython-38.pyc
U
x6�[+ � @ s� d dl Z d dlZd dlZddlmZ ddlmZ ddlmZm Z m
Z
ddlmZ zd dl
mZ W n ek
r| d dl
ZY nX dZd Zd
Ze�d�Zdd
� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zd d!� ZdS )"� N� )�echo)�split_arg_string)�MultiCommand�Option�Argument)�Choice)�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
a9
%(complete_func)s() {
local -a completions
local -a completions_with_descriptions
local -a response
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 -Q
fi
if [ -n "$completions" ]; then
compadd -U -V unsorted -Q -a completions
fi
compstate[insert]="automenu"
}
compdef %(complete_func)s %(script_names)s
z
[^a-zA-Z0-9_]c C s@ t �d| �dd��}|dkr tnt}|d| | |d� �� d S )N� �-�_�zshz_%s_completion)Z
complete_funcZscript_namesZautocomplete_var�;)�_invalid_ident_char_re�sub�replace�COMPLETION_SCRIPT_ZSH�COMPLETION_SCRIPT_BASH�strip)� prog_name�complete_var�shellZcf_nameZscript� r �5/usr/lib/python3/dist-packages/click/_bashcomplete.py�get_completion_scriptK s �
�r c C s� | j ||dd�}|j|j }|r�t|jt�r�|jjst|j�||�\}}}|dkrT|S |j |||dd�}|j|j }q�|r�|j�||�\}}}|dkr�|S |j |||dddd�}|j}qt|}|j|j }qq�q|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 Zallow_extra_argsZallow_interspersed_argsr )Zmake_context�protected_args�args�
isinstance�commandr �chainZresolve_command)�clir r �ctxZcmd_name�cmdZsub_ctxr r r �resolve_ctxU s4
�
�r&