Skip to content

Commit

Permalink
M #-: Add onetemplate to the bash_completition (#4129)
Browse files Browse the repository at this point in the history
+ fix whitespace
  • Loading branch information
xorel committed Jan 29, 2020
1 parent fe63e48 commit 0aacdfa
Showing 1 changed file with 31 additions and 5 deletions.
36 changes: 31 additions & 5 deletions share/scripts/bash_completion.d/one
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ _one_list() {
if [ -n "$2" ]; then
filter="-f $2"
fi
echo $($one_cmd $filter list|sed 1d|awk '{print $1}')
echo $($one_cmd $filter list|sed 1d|awk '{print $1}')
return 0
}

Expand All @@ -22,7 +22,7 @@ _onevm() {
then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
elif [ $COMP_CWORD == 2 ]
elif [ $COMP_CWORD == 2 ]
then
case "$prev" in
show|delete)
Expand All @@ -45,7 +45,7 @@ _onevm() {
return 0
;;
esac
elif [ $COMP_CWORD == 3 ]
elif [ $COMP_CWORD == 3 ]
then
case "$pprev" in
migrate)
Expand All @@ -70,7 +70,7 @@ _onevnet() {
then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
elif [ $COMP_CWORD == 2 ]
elif [ $COMP_CWORD == 2 ]
then
case "$prev" in
create|submit)
Expand Down Expand Up @@ -100,7 +100,7 @@ _onehost() {
then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
elif [ $COMP_CWORD == 2 ]
elif [ $COMP_CWORD == 2 ]
then
case "$prev" in
create|submit)
Expand Down Expand Up @@ -128,3 +128,29 @@ _onehost() {
}

complete -F _onehost onehost

_onetemplate() {
local cur prev opts cmd
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="create clone delete instantiate chgrp chown chmod "
opts+="update rename list show top lock unlock"
cmd=onetemplate
if [ $COMP_CWORD == 1 ]
then
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
elif [ $COMP_CWORD == 2 ]
then
case "$prev" in
create)
COMPREPLY=( $(compgen -A file -- ${cur}) )
return 0
;;
esac
fi

}

complete -F _onetemplate onetemplate

0 comments on commit 0aacdfa

Please sign in to comment.