From 081bdbdaede6dfa810fea27395d2ec1bb0875d1d Mon Sep 17 00:00:00 2001 From: Jan Orel Date: Wed, 29 Jan 2020 10:41:41 +0100 Subject: [PATCH] M #-: Add onetemplate to the bash_completition (#4129) + fix whitespace (cherry picked from commit 0aacdfa667a8b4931a9d730e2ecab38713135788) --- share/scripts/bash_completion.d/one | 36 +++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/share/scripts/bash_completion.d/one b/share/scripts/bash_completion.d/one index 5806b35db5..c55feb0cae 100644 --- a/share/scripts/bash_completion.d/one +++ b/share/scripts/bash_completion.d/one @@ -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 } @@ -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) @@ -45,7 +45,7 @@ _onevm() { return 0 ;; esac - elif [ $COMP_CWORD == 3 ] + elif [ $COMP_CWORD == 3 ] then case "$pprev" in migrate) @@ -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) @@ -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) @@ -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