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