diff options
Diffstat (limited to 'Completion/Debian')
-rw-r--r-- | Completion/Debian/_apt | 401 | ||||
-rw-r--r-- | Completion/Debian/_bug | 61 | ||||
-rw-r--r-- | Completion/Debian/_dpkg | 2 |
3 files changed, 254 insertions, 210 deletions
diff --git a/Completion/Debian/_apt b/Completion/Debian/_apt index fe909bda3..169b5f5f7 100644 --- a/Completion/Debian/_apt +++ b/Completion/Debian/_apt @@ -1,7 +1,7 @@ #compdef apt-get apt-cache apt-cdrom apt-config _apt () { - case "$words[1]" in + case "${words[1]:t}" in apt-get) _apt-get "$@";; apt-cache) _apt-cache "$@";; apt-cdrom) _apt-cdrom "$@";; @@ -17,7 +17,7 @@ _apt_arguments () { funcname="$1" shift - typeset -A canonicalize options + typeset -A canonicalize num_options local short_hasarg short_bool short_intlevel short_configfile short_arbitem local long_hasarg long_bool long_intlevel long_configfile long_arbitem local comp_hasarg='' @@ -28,11 +28,11 @@ _apt_arguments () { type="${1#*:}" case $type in - bool) options[$opts]=1;; - intlevel) options[$opts]=-1;; - configfile) options[$opts]=1;; - arbitem) options[$opts]=-1;; - *) options[$opts]=1 + bool) num_options[$opts]=1;; + intlevel) num_options[$opts]=-1;; + configfile) num_options[$opts]=1;; + arbitem) num_options[$opts]=-1;; + *) num_options[$opts]=1 comp_hasarg="${comp_hasarg}$opts) $type;;"$'\n' type=hasarg;; esac @@ -54,7 +54,7 @@ _apt_arguments () { case \$current_option in ${comp_hasarg}esac" - local short_seq false true bool __bool_ intlevel word word1 nul + local short_seq false true bool bool_prefix intlevel word word1 nul qnul local comp_bool comp_intlevel comp_configfile comp_arbitem comp_long comp_opt local regex_short regex_long regex_all @@ -66,15 +66,16 @@ _apt_arguments () { true=(yes true with on enable) bool=($false $true) - __bool_=(--${^bool}-) + bool_prefix=(--${^bool}-) intlevel='[0-9]##' word=$'[^\0]#\0' word1=$'[^\0]##\0' nul=$'\0' + qnul="\$'\\0'" - comp_bool='compadd "$expl_bool[@]" '"$bool" + comp_bool='_wanted values && compadd "$expl_bool[@]" '"$bool" comp_intlevel= #"_message 'intlevel'" comp_configfile='_files "$expl_configfile[@]"' comp_arbitem= #"_message 'Foo::Bar=bar'" @@ -82,38 +83,30 @@ _apt_arguments () { comp_short=\ 'if [[ $PREFIX = -'"$short_seq"' ]]; then _apt_consume_short ${PREFIX[2,-1]} - tmp1=(${${(M)${(s:,:)${(kj:,:)options[(R)*~0]}}:#-?}#-}) - if [[ $PREFIX = - ]]; then - compadd "$expl_opt[@]" - -${^tmp1} - else - tmp2=(-${^tmp1}) - compadd "$expl_opt[@]" -y "($tmp2)" - ${PREFIX}${^tmp1} - fi + tmp1=(${(M)${(s:,:)${(kj:,:)num_options[(R)*~0]}}:#-?}) + tmp2=(${PREFIX}${^tmp1#-}) + _describe -o option tmp1 tmp2 elif [[ -z "$PREFIX" ]]; then - compadd "$expl_opt[@]" - ${(M)${(s:,:)${(kj:,:)options[(R)*~0]}}:#-?} + tmp1=(${(M)${(s:,:)${(kj:,:)num_options[(R)*~0]}}:#-?}) + _describe -o option tmp1 fi' comp_long=\ -'tmp1="${(j:|:)${(@)${(@M)${(@s:,:)${(@kj:,:)options[(R)*~0]}}:#--*}#--}}" +'tmp1="${(j:|:)${(@)${(@M)${(@s:,:)${(@kj:,:)num_options[(R)*~0]}}:#--*}#--}}" tmp2=(--${(M)^long_bool:#$~tmp1} --${(M)^long_intlevel:#$~tmp1}) -compadd "$expl_opt[@]" - $tmp2 -tmp2=(--${(M)^long_hasarg:#$~tmp1} --${(M)^long_configfile:#$~tmp1} --${(M)^long_arbitem:#$~tmp1}) -compadd "$expl_opt[@]" -S= - $tmp2 -compadd "$expl_opt[@]" -S "" - '"$__bool_" +tmp3=(--${(M)^long_hasarg:#$~tmp1} --${(M)^long_configfile:#$~tmp1} --${(M)^long_arbitem:#$~tmp1}) +_describe -o option tmp2 -- tmp3 -S= -- bool_prefix -S ""' comp_long_prefix=\ -'tmp1="${(j:|:)${(@)${(@M)${(@s:,:)${(@kj:,:)options[(R)*~0]}}:#--*}#--}}" +'tmp1="${(j:|:)${(@)${(@M)${(@s:,:)${(@kj:,:)num_options[(R)*~0]}}:#--*}#--}}" tmp2=($_ra_left${(M)^long_bool:#$~tmp1} $_ra_left${(M)^long_intlevel:#$~tmp1}) -compadd "$expl_opt[@]" - $tmp2 -tmp2=($_ra_left${(M)^long_hasarg:#$~tmp1} $_ra_left${(M)^long_configfile:#$~tmp1} $_ra_left${(M)^long_arbitem:#$~tmp1}) -compadd "$expl_opt[@]" -S= - $tmp2 -tmp1="${(j:|:)${(@)${(@M)${(@s:,:)${(@kj:,:)options[(R)*~0]}}:#-?}#-}}" -tmp2=($_ra_left${(M)^short_bool:#$~tmp1} $_ra_left${(M)^short_intlevel:#$~tmp1}) -compadd "$expl_opt[@]" - $tmp2 -tmp2=($_ra_left${(M)^short_hasarg:#$~tmp1} $_ra_left${(M)^short_configfile:#$~tmp1} $_ra_left${(M)^short_arbitem:#$~tmp1}) -compadd "$expl_opt[@]" -S= - $tmp2' +tmp3=($_ra_left${(M)^long_hasarg:#$~tmp1} $_ra_left${(M)^long_configfile:#$~tmp1} $_ra_left${(M)^long_arbitem:#$~tmp1}) +tmp1="${(j:|:)${(@)${(@M)${(@s:,:)${(@kj:,:)num_options[(R)*~0]}}:#-?}#-}}" +tmp2=("$tmp2[@]" $_ra_left${(M)^short_bool:#$~tmp1} $_ra_left${(M)^short_intlevel:#$~tmp1}) +tmp3=("$tmp3[@]" $_ra_left${(M)^short_hasarg:#$~tmp1} $_ra_left${(M)^short_configfile:#$~tmp1} $_ra_left${(M)^short_arbitem:#$~tmp1}) +_describe -o option tmp2 -- tmp3 -S=' - comp_opt='[[ -prefix - || -z "$compconfig[option_prefix]" ]]'" && { $comp_short; $comp_long }" + comp_opt='{ ! zstyle -T ":completion:${curcontext}:options" prefix-needed || [[ "$PREFIX" = -* ]] }'" && { $comp_short; $comp_long }" regex_short=() regex_long=() @@ -121,206 +114,204 @@ compadd "$expl_opt[@]" -S= - $tmp2' if (( $#short_hasarg )); then regex_short=("$regex_short[@]" - /"$short_seq(${(j:|:)short_hasarg})(=|)" - -'_apt_consume_short ${_ra_match%=}; current_option=${canonicalize[-${${_ra_match%=}[-1]}]}' - \( /"$word1" !"$comp_hasarg" \| /"$nul" /"$word" !"$comp_hasarg" \) \| + /"$short_seq(${(j:|:)short_hasarg})(=|)"/ + -'_apt_consume_short ${match[1]%=}; current_option=${canonicalize[-${${match[1]%=}[-1]}]}' + \( /"$word1"/ :"$comp_hasarg" \| /"$nul"/ /"$word"/ :"$comp_hasarg" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" - /"(${(j:|:)short_hasarg})$nul" - -'_apt_consume_short ${_ra_match[-2]}; current_option=${canonicalize[-${${_ra_match%$nul}[-1]}]}' - /"$word" !"$comp_hasarg" \| - /"(${(j:|:)short_hasarg})=" - -'_apt_consume_short ${_ra_match[-2]}; current_option=${canonicalize[-${${_ra_match%=}[-1]}]}' - \( /"$word1" !"$comp_hasarg" \| /"$nul" /"$word" !"$comp_hasarg" \) \| + /"(${(j:|:)short_hasarg})$nul"/ + -'_apt_consume_short ${match[1][-2]}; current_option=${canonicalize[-${${match[1]%'$qnul'}[-1]}]}' + /"$word"/ :"$comp_hasarg" \| + /"(${(j:|:)short_hasarg})="/ + -'_apt_consume_short ${match[1][-2]}; current_option=${canonicalize[-${${match[1]%=}[-1]}]}' + \( /"$word1"/ :"$comp_hasarg" \| /"$nul"/ /"$word"/ :"$comp_hasarg" \) \| ) fi if (( $#short_bool )); then regex_short=("$regex_short[@]" - /"$short_seq(${(j:|:)short_bool})($nul(${(j:|:)bool})|(${(j:|:)bool})|)$nul" - -"_apt_consume_short \${_ra_match%%($nul(${(j:|:)bool})|(${(j:|:)bool})|)$nul}" \| - /"$short_seq(${(j:|:)short_bool})=" - -"_apt_consume_short \${_ra_match%=}" - \( /"$word1" !"$comp_bool" \| /"$nul" /"$word" !"$comp_bool" \) \| + /"$short_seq(${(j:|:)short_bool})($nul(${(j:|:)bool})|(${(j:|:)bool})|)$nul"/ + -'_apt_consume_short ${match[1]%%('$qnul'('${(j:|:)bool}')|('${(j:|:)bool}')|)'$qnul'}' \| + /"$short_seq(${(j:|:)short_bool})="/ + -'_apt_consume_short ${match[1]%=}' + \( /"$word1"/ :"$comp_bool" \| /"$nul"/ /"$word"/ :"$comp_bool" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" - /"(${(j:|:)short_bool})=" - -"_apt_consume_short \${_ra_match[-2]}" - \( /"$word1" !"$comp_bool" \| /"$nul" /"$word" !"$comp_bool" \) \| - /"(${(j:|:)short_bool})$nul" - -"_apt_consume_short \${_ra_match[-2]}" - /"((${(j:|:)bool})$nul|)" !"$comp_bool" \| + /"(${(j:|:)short_bool})="/ + -'_apt_consume_short ${match[1][-2]}' + \( /"$word1"/ :"$comp_bool" \| /"$nul"/ /"$word"/ :"$comp_bool" \) \| + /"(${(j:|:)short_bool})$nul"/ + -'_apt_consume_short ${match[1][-2]}' + /"((${(j:|:)bool})$nul|)"/ :"$comp_bool" \| ) fi if (( $#short_intlevel )); then regex_short=("$regex_short[@]" - /"$short_seq(${(j:|:)short_intlevel})($nul$intlevel|$intlevel|)$nul" - -"_apt_consume_short \${_ra_match%%($nul$intlevel|$intlevel|)$nul}" \| - /"$short_seq(${(j:|:)short_intlevel})=" - -"_apt_consume_short \${_ra_match%=}" - \( /"$word1" !"$comp_intlevel" \| /"$nul" /"$word" !"$comp_intlevel" \) \| + /"$short_seq(${(j:|:)short_intlevel})($nul$intlevel|$intlevel|)$nul"/ + -'_apt_consume_short ${match[1]%%'"($qnul$intlevel|$intlevel|)$qnul"'}' \| + /"$short_seq(${(j:|:)short_intlevel})="/ + -'_apt_consume_short ${match[1]%=}' + \( /"$word1"/ :"$comp_intlevel" \| /"$nul"/ /"$word"/ :"$comp_intlevel" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" - /"(${(j:|:)short_intlevel})=" - -"_apt_consume_short \${_ra_match[-2]}" - \( /"$word1" !"$comp_intlevel" \| /"$nul" /"$word" !"$comp_intlevel" \) \| - /"(${(j:|:)short_intlevel})$nul" - -"_apt_consume_short \${_ra_match[-2]}" - /"($intlevel$nul|)" !"$comp_intlevel" \| + /"(${(j:|:)short_intlevel})="/ + -'_apt_consume_short ${match[1][-2]}' + \( /"$word1"/ :"$comp_intlevel" \| /"$nul"/ /"$word"/ :"$comp_intlevel" \) \| + /"(${(j:|:)short_intlevel})$nul"/ + -'_apt_consume_short ${match[1][-2]}' + /"($intlevel$nul|)"/ :"$comp_intlevel" \| ) fi if (( $#short_configfile )); then regex_short=("$regex_short[@]" - /"$short_seq(${(j:|:)short_configfile})(=|)" - -"_apt_consume_short \${_ra_match%=}" - \( /"$word1" !"$comp_configfile" \| /"$nul" /"$word" !"$comp_configfile" \) \| + /"$short_seq(${(j:|:)short_configfile})(=|)"/ + -'_apt_consume_short ${match[1]%=}' + \( /"$word1"/ :"$comp_configfile" \| /"$nul"/ /"$word"/ :"$comp_configfile" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" - /"(${(j:|:)short_configfile})$nul" - -"_apt_consume_short \${_ra_match[-2]}" - /"$word" !"$comp_configfile" \| - /"(${(j:|:)short_configfile})=" - -"_apt_consume_short \${_ra_match[-2]}" - \( /"$word1" !"$comp_configfile" \| /"$nul" /"$word" !"$comp_configfile" \) \| + /"(${(j:|:)short_configfile})$nul"/ + -'_apt_consume_short ${match[1][-2]}' + /"$word"/ :"$comp_configfile" \| + /"(${(j:|:)short_configfile})="/ + -'_apt_consume_short ${match[1][-2]}' + \( /"$word1"/ :"$comp_configfile" \| /"$nul"/ /"$word"/ :"$comp_configfile" \) \| ) fi if (( $#short_arbitem )); then regex_short=("$regex_short[@]" - /"$short_seq(${(j:|:)short_arbitem})(=|)" - -"_apt_consume_short \${_ra_match%=}" - \( /"$word1" !"$comp_arbitem" \| /"$nul" /"$word" !"$comp_arbitem" \) \| + /"$short_seq(${(j:|:)short_arbitem})(=|)"/ + -'_apt_consume_short ${match[1]%=}' + \( /"$word1"/ :"$comp_arbitem" \| /"$nul"/ /"$word"/ :"$comp_arbitem" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" - /"(${(j:|:)short_arbitem})$nul" - -"_apt_consume_short \${_ra_match[-2]}" - /"$word" !"$comp_arbitem" \| - /"(${(j:|:)short_arbitem})=" - -"_apt_consume_short \${_ra_match[-2]}" - \( /"$word1" !"$comp_arbitem" \| /"$nul" /"$word" !"$comp_arbitem" \) \| + /"(${(j:|:)short_arbitem})$nul"/ + -'_apt_consume_short ${match[1][-2]}' + /"$word"/ :"$comp_arbitem" \| + /"(${(j:|:)short_arbitem})="/ + -'_apt_consume_short ${match[1][-2]}' + \( /"$word1"/ :"$comp_arbitem" \| /"$nul"/ /"$word"/ :"$comp_arbitem" \) \| ) fi if (( $#long_hasarg )); then regex_long=("$regex_long[@]" - /"(${(j:|:)long_hasarg})$nul" - -"_apt_consume_long \${_ra_match%$nul}; current_option=\${canonicalize[--\${_ra_match%$nul}]}" - /"$word" !"$comp_hasarg" \| - /"(${(j:|:)long_hasarg})=" - -"_apt_consume_long \${_ra_match%=}; current_option=\${canonicalize[--\${_ra_match%=}]}" - \( /"$word1" !"$comp_hasarg" \| /"$nul" /"$word" !"$comp_hasarg" \) \| + /"(${(j:|:)long_hasarg})$nul"/ + -'_apt_consume_long ${match[1]%'$qnul'}; current_option=${canonicalize[--${match[1]%'$qnul'}]}' + /"$word"/ :"$comp_hasarg" \| + /"(${(j:|:)long_hasarg})="/ + -'_apt_consume_long ${match[1]%=}; current_option=${canonicalize[--${match[1]%=}]}' + \( /"$word1"/ :"$comp_hasarg" \| /"$nul"/ /"$word"/ :"$comp_hasarg" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" - /"(${(j:|:)long_hasarg})$nul" - -"_apt_consume_long \${_ra_match%$nul}; current_option=\${canonicalize[--\${_ra_match%$nul}]}" - /"$word" !"$comp_hasarg" \| - /"(${(j:|:)long_hasarg})=" - -"_apt_consume_long \${_ra_match%=}; current_option=\${canonicalize[--\${_ra_match%=}]}" - \( /"$word1" !"$comp_hasarg" \| /"$nul" /"$word" !"$comp_hasarg" \) \| + /"(${(j:|:)long_hasarg})$nul"/ + -'_apt_consume_long ${match[1]%'$qnul'}; current_option=${canonicalize[--${match[1]%'$qnul'}]}' + /"$word"/ :"$comp_hasarg" \| + /"(${(j:|:)long_hasarg})="/ + -'_apt_consume_long ${match[1]%=}; current_option=${canonicalize[--${match[1]%=}]}' + \( /"$word1"/ :"$comp_hasarg" \| /"$nul"/ /"$word"/ :"$comp_hasarg" \) \| ) fi if (( $#long_bool )); then regex_long=("$regex_long[@]" - /"(${(j:|:)long_bool})=" - -"_apt_consume_long \${_ra_match%=}" - \( /"$word1" !"$comp_bool" \| /"$nul" /"$word" !"$comp_bool" \) \| - /"(${(j:|:)long_bool})$nul" - -"_apt_consume_long \${_ra_match%$nul}" - /"((${(j:|:)bool})$nul|)" !"$comp_bool" \| + /"(${(j:|:)long_bool})="/ + -'_apt_consume_long ${match[1]%=}' + \( /"$word1"/ :"$comp_bool" \| /"$nul"/ /"$word"/ :"$comp_bool" \) \| + /"(${(j:|:)long_bool})$nul"/ + -'_apt_consume_long ${match[1]%'$qnul'}' + /"((${(j:|:)bool})$nul|)"/ :"$comp_bool" \| ) regex_long_prefix=("$regex_long_prefix[@]" - /"(${(j:|:)long_bool})=" - -"_apt_consume_long \${_ra_match%=}" - \( /"$word1" !"$comp_bool" \| /"$nul" /"$word" !"$comp_bool" \) \| - /"(${(j:|:)long_bool})$nul" - -"_apt_consume_long \${_ra_match%$nul}" - /"((${(j:|:)bool})$nul|)" !"$comp_bool" \| + /"(${(j:|:)long_bool})="/ + -'_apt_consume_long ${match[1]%=}' + \( /"$word1"/ :"$comp_bool" \| /"$nul"/ /"$word"/ :"$comp_bool" \) \| + /"(${(j:|:)long_bool})$nul"/ + -'_apt_consume_long ${match[1]%'$qnul'}' + /"((${(j:|:)bool})$nul|)"/ :"$comp_bool" \| ) fi if (( $#long_intlevel )); then regex_long=("$regex_long[@]" - /"(${(j:|:)long_intlevel})=" - -"_apt_consume_long \${_ra_match%=}" - \( /"$word1" !"$comp_intlevel" \| /"$nul" /"$word" !"$comp_intlevel" \) \| - /"(${(j:|:)long_intlevel})$nul" - -"_apt_consume_long \${_ra_match%$nul}" - /"($intlevel$nul|)" !"$comp_intlevel" \| + /"(${(j:|:)long_intlevel})="/ + -'_apt_consume_long ${match[1]%=}' + \( /"$word1"/ :"$comp_intlevel" \| /"$nul"/ /"$word"/ :"$comp_intlevel" \) \| + /"(${(j:|:)long_intlevel})$nul"/ + -'_apt_consume_long ${match[1]%'$qnul'}' + /"($intlevel$nul|)"/ :"$comp_intlevel" \| ) regex_long_prefix=("$regex_long_prefix[@]" - /"(${(j:|:)long_intlevel})$nul" - -"_apt_consume_long \${_ra_match%$nul}" - /"$intlevel" !"$comp_intlevel" /"$nul" \| - /"(${(j:|:)long_intlevel})=" - -"_apt_consume_long \${_ra_match%=}" - \( /"$word1" !"$comp_intlevel" \| /"$nul" /"$word" !"$comp_intlevel" \) \| - /"(${(j:|:)long_intlevel})$nul" - -"_apt_consume_long \${_ra_match%$nul}" - /"($intlevel$nul|)" !"$comp_intlevel" \| + /"(${(j:|:)long_intlevel})="/ + -'_apt_consume_long ${match[1]%=}' + \( /"$word1"/ :"$comp_intlevel" \| /"$nul"/ /"$word"/ :"$comp_intlevel" \) \| + /"(${(j:|:)long_intlevel})$nul"/ + -'_apt_consume_long ${match[1]%'$qnul'}' + /"($intlevel$nul|)"/ :"$comp_intlevel" \| ) fi if (( $#long_configfile )); then regex_long=("$regex_long[@]" - /"(${(j:|:)long_configfile})$nul" - -"_apt_consume_long \${_ra_match%$nul}" - /"$word" !"$comp_configfile" \| - /"(${(j:|:)long_configfile})=" - -"_apt_consume_long \${_ra_match%=}" - \( /"$word1" !"$comp_configfile" \| /"$nul" /"$word" !"$comp_configfile" \) \| + /"(${(j:|:)long_configfile})$nul"/ + -'_apt_consume_long ${match[1]%'$qnul'}' + /"$word"/ :"$comp_configfile" \| + /"(${(j:|:)long_configfile})="/ + -'_apt_consume_long ${match[1]%=}' + \( /"$word1"/ :"$comp_configfile" \| /"$nul"/ /"$word"/ :"$comp_configfile" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" - /"(${(j:|:)long_configfile})$nul" - -"_apt_consume_long \${_ra_match%$nul}" - /"$word" !"$comp_configfile" \| - /"(${(j:|:)long_configfile})=" - -"_apt_consume_long \${_ra_match%=}" - \( /"$word1" !"$comp_configfile" \| /"$nul" /"$word" !"$comp_configfile" \) \| + /"(${(j:|:)long_configfile})$nul"/ + -'_apt_consume_long ${match[1]%'$qnul'}' + /"$word"/ :"$comp_configfile" \| + /"(${(j:|:)long_configfile})="/ + -'_apt_consume_long ${match[1]%=}' + \( /"$word1"/ :"$comp_configfile" \| /"$nul"/ /"$word"/ :"$comp_configfile" \) \| ) fi if (( $#long_arbitem )); then regex_long=("$regex_long[@]" - /"(${(j:|:)long_arbitem})$nul" - -"_apt_consume_long \${_ra_match%$nul}" - /"$word" !"$comp_arbitem" \| - /"(${(j:|:)long_arbitem})=" - -"_apt_consume_long \${_ra_match%=}" - \( /"$word1" !"$comp_arbitem" \| /"$nul" /"$word" !"$comp_arbitem" \) \| + /"(${(j:|:)long_arbitem})$nul"/ + -'_apt_consume_long ${match[1]%'$qnul'}' + /"$word"/ :"$comp_arbitem" \| + /"(${(j:|:)long_arbitem})="/ + -'_apt_consume_long ${match[1]%=}' + \( /"$word1"/ :"$comp_arbitem" \| /"$nul"/ /"$word"/ :"$comp_arbitem" \) \| ) regex_long_prefix=("$regex_long_prefix[@]" - /"(${(j:|:)long_arbitem})$nul" - -"_apt_consume_long \${_ra_match%$nul}" - /"$word" !"$comp_arbitem" \| - /"(${(j:|:)long_arbitem})=" - -"_apt_consume_long \${_ra_match%=}" - \( /"$word1" !"$comp_arbitem" \| /"$nul" /"$word" !"$comp_arbitem" \) \| + /"(${(j:|:)long_arbitem})$nul"/ + -'_apt_consume_long ${match[1]%'$qnul'}' + /"$word"/ :"$comp_arbitem" \| + /"(${(j:|:)long_arbitem})="/ + -'_apt_consume_long ${match[1]%=}' + \( /"$word1"/ :"$comp_arbitem" \| /"$nul"/ /"$word"/ :"$comp_arbitem" \) \| ) fi regex_all=( - /"$word" - \( %-- \( "$regex_long[@]" - %"(${(j:|:)bool})-" - \( "$regex_long_prefix[@]" /"[]" !"$comp_long_prefix" \) \| - /"[]" !"$comp_long" \) \| - %- \( "$regex_short[@]" /"[]" !"$comp_short; $comp_long" \) \| - /"[]" !"$comp_opt" \) \# + /"$word"/ + \( /--/+ \( "$regex_long[@]" + /"(${(j:|:)bool})-"/+ + \( "$regex_long_prefix[@]" + /"[]"/ :"$comp_long_prefix" \) \) \| + /-/+ \( "$regex_short[@]" /"[]"/ \) \| + /"[]"/ :"$comp_opt" \) \# "$regex_all[@]" ) _regex_arguments "${funcname}_sm" "$regex_all[@]" eval "$funcname () { - typeset -A canonicalize options + typeset -A canonicalize num_options canonicalize=(${(kv)canonicalize}) - options=(${(kv)options}) + num_options=(${(kv)num_options}) local short_hasarg short_bool short_intlevel short_configfile short_arbitem local long_hasarg long_bool long_intlevel long_configfile long_arbitem + local bool_prefix short_hasarg=($short_hasarg) short_bool=($short_bool) short_intlevel=($short_intlevel) @@ -331,13 +322,14 @@ compadd "$expl_opt[@]" -S= - $tmp2' long_intlevel=($long_intlevel) long_configfile=($long_configfile) long_arbitem=($long_arbitem) + bool_prefix=($bool_prefix) local expl_opt expl_bool expl_configfile - _description expl_opt option - _description expl_bool 'bool value' - _description expl_configfile 'config file' + _description options expl_opt option + _description values expl_bool 'boolean value' + _description files expl_configfile 'config file' - local current_option tmp1 tmp2 + local current_option tmp1 tmp2 tmp3 ${funcname}_sm }" @@ -347,14 +339,16 @@ _apt_consume_short () { local short opt for short in ${(s::)1}; do opt="$canonicalize[-$short]" - (( 0 < options[$opt] && options[$opt]-- )) + (( 0 < num_options[$opt] && num_options[$opt]-- )) done + return 0 } _apt_consume_long () { local long opt opt="$canonicalize[--$1]" - (( 0 < options[$opt] && options[$opt]-- )) + (( 0 < num_options[$opt] && num_options[$opt]-- )) + return 0 } _apt-get () { @@ -374,26 +368,28 @@ _apt-get () { --no-upgrade:bool \ --force-yes:bool \ --print-uris:bool \ + --purge:bool \ + --list-cleanup:bool \ -c,--config-file:configfile \ -o,--option:arbitem \ -- \ - /$'update\0' \| \ - /$'upgrade\0' \| \ - /$'install\0' /$'[^\0]#\0' !'_deb_packages uninstalled "$expl_packages[@]" || _deb_packages installed "$expl_packages[@]" ' \# \| \ - /$'remove\0' /$'[^\0]#\0' !'_deb_packages installed "$expl_packages[@]"' \# \| \ - /$'dist-upgrade\0' \| \ - /$'dselect-upgrade\0' \| \ - /$'clean\0' \| \ - /$'autoclean\0' \| \ - /$'check\0' \| \ - /$'source\0' /$'[^\0]#\0' !'_deb_packages avail "$expl_packages[@]"' \# \| \ - /$'help\0' \| \ - /"[]" !'compadd "$expl_action[@]" update upgrade install remove dist-upgrade dselect-upgrade clean autoclean check source help' + /$'update\0'/ \| \ + /$'upgrade\0'/ \| \ + /$'install\0'/ /$'[^\0]#\0'/ :'_deb_packages "$expl_packages[@]" uninstalled || _deb_packages "$expl_packages[@]" installed' \# \| \ + /$'remove\0'/ /$'[^\0]#\0'/ :'_deb_packages "$expl_packages[@]" installed' \# \| \ + /$'dist-upgrade\0'/ \| \ + /$'dselect-upgrade\0'/ \| \ + /$'clean\0'/ \| \ + /$'autoclean\0'/ \| \ + /$'check\0'/ \| \ + /$'source\0'/ /$'[^\0]#\0'/ :'_deb_packages "$expl_packages[@]" avail' \# \| \ + /$'help\0/' \| \ + /"[]"/ :'_wanted actions expl_action action compadd update upgrade install remove dist-upgrade dselect-upgrade clean autoclean check source help' _apt-get () { local expl_action expl_packages - _description expl_action 'action' - _description expl_packages 'package' + _description actions expl_action 'action' + _description packages expl_packages 'package' _apt-get_sm } @@ -414,25 +410,26 @@ _apt-cache () { -c,--config-file:configfile \ -o,--option:arbitem \ -- \ - /$'help\0' \| \ - /$'add\0' /$'[^\0]#\0' !'_files' \# \| \ - /$'gencaches\0' \| \ - /$'showpkg\0' /$'[^\0]#\0' !'_deb_packages avail "$expl_packages[@]"' \# \| \ - /$'stats\0' \| \ - /$'dump\0' \| \ - /$'dumpavail\0' \| \ - /$'unmet\0' \| \ - /$'check\0' \| \ - /$'search\0' \| \ - /$'show\0' \| \ - /"[]" !'compadd "$expl_action[@]" help add gencaches showpkg stats dump dumpavail unmet check search show' + /$'help\0'/ \| \ + /$'add\0'/ /$'[^\0]#\0'/ :'_files' \# \| \ + /$'gencaches\0'/ \| \ + /$'showpkg\0'/ /$'[^\0]#\0'/ :'_deb_packages "$expl_packages[@]" avail' \# \| \ + /$'stats\0'=$status[4]/ \| \ + /$'dump\0'/ \| \ + /$'dumpavail\0'/ \| \ + /$'unmet\0'/ \| \ + /$'check\0'/ \| \ + /$'search\0'/ /$'[^\0]#\0'/ :'_message "pattern"' \| \ + /$'show\0'/ /$'[^\0]#\0'/ :'_deb_packages "$expl_packages[@]" avail' \# \| \ + /$'depends\0'/ \| \ + /"[]"/ :'_wanted actions expl_action action compadd help add gencaches showpkg stats dump dumpavail unmet check search show depends' _apt-cache () { local expl_action expl_packages expl_pkg_cache expl_src_cache - _description expl_action 'action' - _description expl_packages 'package' - _description expl_pkg_cache 'package cache' - _description expl_src_cache 'source cache' + _description actions expl_action 'action' + _description packages expl_packages 'package' + _description files expl_pkg_cache 'package cache' + _description files expl_src_cache 'source cache' _apt-cache_sm } @@ -453,13 +450,13 @@ _apt-cdrom () { -c,--config-file:configfile \ -o,--option:arbitem \ -- \ - /$'add\0' \| \ - /"[]" !'compadd "$expl_action[@]" add' + /$'add\0'/ \| \ + /"[]"/ :'_wanted actions expl_action action compadd add' _apt-cdrom () { local expl_action expl_mount_point - _description expl_action 'action' - _description expl_mount_point 'mount point' + _description actions expl_action 'action' + _description files expl_mount_point 'mount point' _apt-cdrom_sm } @@ -474,19 +471,19 @@ _apt-config () { -c,--config-file:configfile \ -o,--option:arbitem \ -- \ - /$'shell\0' \ + /$'shell\0'/ \ \( \ - /$'[^\0]#\0' !'compgen "$expl_shell_var[@]" -v' \ - /$'[^\0]#\0' !'compadd "$expl_config_key[@]" - ${${(f)"$(apt-config dump 2>&1)"}% *}' \ + /$'[^\0]#\0'/ :'_wanted parameters expl_shell_var "shell variable to assign" compadd - "${(@k)parameters}"' \ + /$'[^\0]#\0'/ :'_wanted configuration-keys expl_config_key "configuration key" compadd - ${${(f)"$(apt-config dump 2>&1)"}% *}' \ \) \# \| \ - /$'dump\0' \| \ - /"[]" !'compadd "$expl_action[@]" shell dump' + /$'dump\0'/ \| \ + /"[]"/ :'_wanted actions expl_action action compadd shell dump' _apt-config () { local expl_action expl_shell_var expl_config_key - _description expl_action 'action' - _description expl_shell_var 'shell variable to assign' - _description expl_config_key 'configuration key' + _description actions expl_action 'action' + _description parameters expl_shell_var 'shell variable to assign' + _description configuration-keys expl_config_key 'configuration key' _apt-config_sm } diff --git a/Completion/Debian/_bug b/Completion/Debian/_bug index 376fa0135..ee6046a12 100644 --- a/Completion/Debian/_bug +++ b/Completion/Debian/_bug @@ -1,15 +1,62 @@ -#compdef bug +#compdef bug reportbug -_arguments '-c[exclude configs from report]' \ - '-d[debug - send mail to postmaster@localhost]' \ - '-f[argument is a file, not a package]' \ - '-H[special header]:custom header:' \ +_bug_commonargs=('-d[debug: send mail to postmaster@localhost]' \ '-m[maintainer-only]' \ '-p[print to stdout instead of mail]' \ '-q[quiet - no e-mail forwarding]' \ + '-h[help]' \ + '-v[version]' \ + '*:package:_deb_packages installed') + +case "${words[1]:t}" in +bug) +_arguments '-c[exclude configs from report]' \ + '-f[argument is a file, not a package]' \ + '-H[special header]:custom header:' \ '-s[set subject]:subject:' \ '-S[set severity]:severity:(wishlist normal important grave critical)' \ '-x[do not cc submitter]' \ '-z[send configs verbatim]' \ - '-h[help]' \ - '*:package:_deb_packages installed' + "$_bug_commonargs[@]" +;; + +reportbug) +_arguments '(--no-config-files)-c[exclude configs from report]' \ + '(-c)--no-config-files' \ + '(--file)-f[argument is a file, not a package]:filename:' \ + '(-f)--file=:filename:' \ + '(--header)-H[special header]:custom header:' \ + '(-H)--header=:custom header:' \ + '(--subject)-s[set subject]:subject:' \ + '(-s)--subject=:subject:' \ + '(--severity)-S[set severity]:severity:(wishlist normal important grave critical)' \ + '(-S)--severity=:severity:(wishlist normal important grave critical)' \ + '(--no-cc)-x[do not cc submitter]' \ + '(-x)--no-cc' \ + '(--no-compress)-z[send configs verbatim]' \ + '(-z)--no-compress[send configs verbatim]' \ + '(--af)-a[use af instead of editor]' \ + '(-a)--af[use af instead of editor]' \ + '(--no-bts-query)-b[do not check bts]' \ + '(-b)--no-bts-query' \ + '(--bts)-B[use alternate BTS]:system:(debian gnome kde tdyc)' \ + '(-B)--bts=:system:(debian gnome kde tdyc)' \ + '-g[sign report with GnuPG]' \ + '(--include)-i[include text]:' \ + '(-i)--include=:' \ + '(--no-ldap)-l[disable LDAP support]' \ + '(-l)--no-ldap' \ + '(--mutt)-M[use mutt instead of editor]' \ + '(-M)--mutt' \ + '--mua=[use specified mua instead of editor]' \ + '(--nmh --mh)-n[use comp instead of editor]' \ + '(-n --mh)--nmh' \ + '(--nmh -n)--mh' \ + '(--output)-o[output to file instead of mail]' \ + '(-o)--output=' \ + '(--pgp)-P[sign report with PGP]' \ + '(-P)--pgp' \ + '--ldap[enable LDAP support]' \ + "$_bug_commonargs[@]" +;; +esac diff --git a/Completion/Debian/_dpkg b/Completion/Debian/_dpkg index 4e10844a2..43325c636 100644 --- a/Completion/Debian/_dpkg +++ b/Completion/Debian/_dpkg @@ -20,7 +20,7 @@ _dpkg_common_args=('--help[show help]' \ '--version[show version]' \ '--licence[show licensing]') -case "$words[1]" in +case "${words[1]:t}" in dpkg) _arguments -s '(--install)-i[install packages]:Debian package:_files -g \*.deb' \ '(-i)--install:Debian package:_files -g \*.deb' \ |