Use _init_completion() in completions/_*.
This commit is contained in:
parent
955219bf69
commit
ab29cef65a
@ -7,24 +7,23 @@ have mock || return
|
|||||||
|
|
||||||
_mock()
|
_mock()
|
||||||
{
|
{
|
||||||
local cur prev plugins cfgdir split=false
|
local cur prev words cword
|
||||||
|
_init_completion || return
|
||||||
|
|
||||||
COMPREPLY=()
|
local plugins='tmpfs root_cache yum_cache bind_mount ccache'
|
||||||
_get_comp_words_by_ref cur prev
|
local cfgdir=/etc/mock count=0 i
|
||||||
plugins='tmpfs root_cache yum_cache bind_mount ccache'
|
|
||||||
cfgdir=/etc/mock
|
|
||||||
|
|
||||||
count=0
|
for i in "${words[@]}" ; do
|
||||||
for i in "${COMP_WORDS[@]}" ; do
|
[ $count -eq $cword ] && break
|
||||||
[ $count -eq $COMP_CWORD ] && break
|
|
||||||
if [[ "$i" == --configdir ]] ; then
|
if [[ "$i" == --configdir ]] ; then
|
||||||
cfgdir="${COMP_WORDS[((count+1))]}"
|
cfgdir="${words[((count+1))]}"
|
||||||
elif [[ "$i" == --configdir=* ]] ; then
|
elif [[ "$i" == --configdir=* ]] ; then
|
||||||
cfgdir=${i/*=/}
|
cfgdir=${i/*=/}
|
||||||
fi
|
fi
|
||||||
count=$((++count))
|
count=$((++count))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
local split=false
|
||||||
_split_longopt && split=true
|
_split_longopt && split=true
|
||||||
|
|
||||||
case $prev in
|
case $prev in
|
||||||
|
@ -46,20 +46,19 @@ _module_avail ()
|
|||||||
# A completion function for the module alias
|
# A completion function for the module alias
|
||||||
_module ()
|
_module ()
|
||||||
{
|
{
|
||||||
local cur prev options
|
local cur prev words cword
|
||||||
|
_init_completion || return
|
||||||
|
|
||||||
COMPREPLY=()
|
if [ $cword -eq 1 ] ; then
|
||||||
_get_comp_words_by_ref cur prev
|
|
||||||
|
|
||||||
if [ $COMP_CWORD -eq 1 ] ; then
|
|
||||||
# First parameter on line -- we expect it to be a mode selection
|
# First parameter on line -- we expect it to be a mode selection
|
||||||
|
|
||||||
|
local options
|
||||||
options="$( module help 2>&1 | command grep -E '^[[:space:]]*\+' | \
|
options="$( module help 2>&1 | command grep -E '^[[:space:]]*\+' | \
|
||||||
awk '{print $2}' | sed -e 's/|/ /g' | sort )"
|
awk '{print $2}' | sed -e 's/|/ /g' | sort )"
|
||||||
|
|
||||||
COMPREPLY=( $(compgen -W "$options" -- "$cur") )
|
COMPREPLY=( $(compgen -W "$options" -- "$cur") )
|
||||||
|
|
||||||
elif [ $COMP_CWORD -eq 2 ] ; then
|
elif [ $cword -eq 2 ] ; then
|
||||||
case $prev in
|
case $prev in
|
||||||
add|display|help|load|show|whatis)
|
add|display|help|load|show|whatis)
|
||||||
COMPREPLY=( $(_module_avail "$cur") )
|
COMPREPLY=( $(_module_avail "$cur") )
|
||||||
@ -71,8 +70,8 @@ _module ()
|
|||||||
COMPREPLY=( $(_module_path "$cur") )
|
COMPREPLY=( $(_module_path "$cur") )
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
elif [ $COMP_CWORD -eq 3 ] ; then
|
elif [ $cword -eq 3 ] ; then
|
||||||
case ${COMP_WORDS[1]} in
|
case ${words[1]} in
|
||||||
swap|switch)
|
swap|switch)
|
||||||
COMPREPLY=( $(_module_avail "$cur") )
|
COMPREPLY=( $(_module_avail "$cur") )
|
||||||
;;
|
;;
|
||||||
|
@ -7,11 +7,10 @@ have svn || return
|
|||||||
|
|
||||||
_svn()
|
_svn()
|
||||||
{
|
{
|
||||||
local cur prev commands options command
|
local cur prev words cword
|
||||||
|
_init_completion || return
|
||||||
COMPREPLY=()
|
|
||||||
_get_comp_words_by_ref cur prev
|
|
||||||
|
|
||||||
|
local commands
|
||||||
commands='add blame praise annotate ann cat checkout co cleanup commit \
|
commands='add blame praise annotate ann cat checkout co cleanup commit \
|
||||||
ci copy cp delete del remove rm diff di export help ? h import \
|
ci copy cp delete del remove rm diff di export help ? h import \
|
||||||
info list ls lock log merge mkdir move mv rename ren \
|
info list ls lock log merge mkdir move mv rename ren \
|
||||||
@ -19,7 +18,7 @@ _svn()
|
|||||||
proplist plist pl propset pset ps resolved revert \
|
proplist plist pl propset pset ps resolved revert \
|
||||||
status stat st switch sw unlock update up'
|
status stat st switch sw unlock update up'
|
||||||
|
|
||||||
if [[ $COMP_CWORD -eq 1 ]] ; then
|
if [[ $cword -eq 1 ]] ; then
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
COMPREPLY=( $( compgen -W '--version' -- $cur ) )
|
COMPREPLY=( $( compgen -W '--version' -- $cur ) )
|
||||||
else
|
else
|
||||||
@ -42,17 +41,18 @@ _svn()
|
|||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
--editor-cmd|--diff-cmd|--diff3-cmd)
|
--editor-cmd|--diff-cmd|--diff3-cmd)
|
||||||
COMP_WORDS=(COMP_WORDS[0] $cur)
|
words=(words[0] $cur)
|
||||||
COMP_CWORD=1
|
cword=1
|
||||||
_command
|
_command
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
command=${COMP_WORDS[1]}
|
local command=${words[1]}
|
||||||
|
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
# possible options for the command
|
# possible options for the command
|
||||||
|
local options
|
||||||
case $command in
|
case $command in
|
||||||
add)
|
add)
|
||||||
options='--auto-props --no-auto-props --force --targets
|
options='--auto-props --no-auto-props --force --targets
|
||||||
@ -220,15 +220,14 @@ complete -F _svn svn
|
|||||||
|
|
||||||
_svnadmin()
|
_svnadmin()
|
||||||
{
|
{
|
||||||
local cur prev commands options mode
|
local cur prev words cword
|
||||||
|
_init_completion || return
|
||||||
COMPREPLY=()
|
|
||||||
_get_comp_words_by_ref cur prev
|
|
||||||
|
|
||||||
|
local commands
|
||||||
commands='create deltify dump help ? hotcopy list-dblogs list-unused-dblogs
|
commands='create deltify dump help ? hotcopy list-dblogs list-unused-dblogs
|
||||||
load lslocks lstxns recover rmlocks rmtxns setlog verify'
|
load lslocks lstxns recover rmlocks rmtxns setlog verify'
|
||||||
|
|
||||||
if [[ $COMP_CWORD -eq 1 ]] ; then
|
if [[ $cword -eq 1 ]] ; then
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
COMPREPLY=( $( compgen -W '--version' -- $cur ) )
|
COMPREPLY=( $( compgen -W '--version' -- $cur ) )
|
||||||
else
|
else
|
||||||
@ -246,10 +245,11 @@ _svnadmin()
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
command=${COMP_WORDS[1]}
|
local command=${words[1]}
|
||||||
|
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
# possible options for the command
|
# possible options for the command
|
||||||
|
local options
|
||||||
case $command in
|
case $command in
|
||||||
create)
|
create)
|
||||||
options='--bdb-txn-nosync --bdb-log-keep --config-dir
|
options='--bdb-txn-nosync --bdb-log-keep --config-dir
|
||||||
@ -293,25 +293,25 @@ complete -F _svnadmin -o default svnadmin
|
|||||||
|
|
||||||
_svnlook()
|
_svnlook()
|
||||||
{
|
{
|
||||||
local cur prev commands options mode
|
local cur prev words cword
|
||||||
|
_init_completion || return
|
||||||
COMPREPLY=()
|
|
||||||
_get_comp_words_by_ref cur
|
|
||||||
|
|
||||||
|
local commands
|
||||||
commands='author cat changed date diff dirs-changed help ? h history info
|
commands='author cat changed date diff dirs-changed help ? h history info
|
||||||
lock log propget pget pg proplist plist pl tree uuid youngest'
|
lock log propget pget pg proplist plist pl tree uuid youngest'
|
||||||
|
|
||||||
if [[ $COMP_CWORD -eq 1 ]] ; then
|
if [[ $cword -eq 1 ]] ; then
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
COMPREPLY=( $( compgen -W '--version' -- $cur ) )
|
COMPREPLY=( $( compgen -W '--version' -- $cur ) )
|
||||||
else
|
else
|
||||||
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
|
COMPREPLY=( $( compgen -W "$commands" -- $cur ) )
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
command=${COMP_WORDS[1]}
|
local command=${words[1]}
|
||||||
|
|
||||||
if [[ "$cur" == -* ]]; then
|
if [[ "$cur" == -* ]]; then
|
||||||
# possible options for the command
|
# possible options for the command
|
||||||
|
local options
|
||||||
case $command in
|
case $command in
|
||||||
author|cat|date|dirs-changed|info|log)
|
author|cat|date|dirs-changed|info|log)
|
||||||
options='-r --revision -t --transaction'
|
options='-r --revision -t --transaction'
|
||||||
|
@ -37,14 +37,13 @@ _yum_plugins()
|
|||||||
|
|
||||||
_yum()
|
_yum()
|
||||||
{
|
{
|
||||||
local cur prev special i split=false
|
local cur prev words cword
|
||||||
|
_init_completion || return
|
||||||
|
|
||||||
COMPREPLY=()
|
local special i
|
||||||
_get_comp_words_by_ref cur prev
|
for (( i=0; i < ${#words[@]}-1; i++ )); do
|
||||||
|
if [[ ${words[i]} == @(install|update|upgrade|remove|erase|deplist|info) ]]; then
|
||||||
for (( i=0; i < ${#COMP_WORDS[@]}-1; i++ )); do
|
special=${words[i]}
|
||||||
if [[ ${COMP_WORDS[i]} == @(install|update|upgrade|remove|erase|deplist|info) ]]; then
|
|
||||||
special=${COMP_WORDS[i]}
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -75,6 +74,7 @@ _yum()
|
|||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local split=false
|
||||||
_split_longopt && split=true
|
_split_longopt && split=true
|
||||||
|
|
||||||
case $prev in
|
case $prev in
|
||||||
|
@ -7,10 +7,8 @@ have repomanage || return
|
|||||||
|
|
||||||
_repomanage()
|
_repomanage()
|
||||||
{
|
{
|
||||||
local cur prev
|
local cur prev words cword
|
||||||
|
_init_completion || return
|
||||||
COMPREPLY=()
|
|
||||||
_get_comp_words_by_ref cur prev
|
|
||||||
|
|
||||||
[[ "$prev" == -@(h|-help|k|-keep) ]] && return 0
|
[[ "$prev" == -@(h|-help|k|-keep) ]] && return 0
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user