From 8e105ca54de6c4f8568a82d11a6c294ca7af5933 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 14 Oct 2012 16:49:26 +0200 Subject: [PATCH] add bash completion --- appconftest/bash/yunohost | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 appconftest/bash/yunohost diff --git a/appconftest/bash/yunohost b/appconftest/bash/yunohost new file mode 100644 index 00000000..2bcb6963 --- /dev/null +++ b/appconftest/bash/yunohost @@ -0,0 +1,33 @@ +# yuno-repo(1) completion + +_yunohost() +{ +local argc cur prev opts +COMPREPLY=() + +argc=${COMP_CWORD} +cur="${COMP_WORDS[argc]}" +prev="${COMP_WORDS[argc-1]}" +opts=$(yunohost2 -h | grep usage | awk -F"{" '{print $2}' | awk -F"}" '{print $1}' | tr ',' ' ') + +if [[ $argc = 1 ]]; +then + COMPREPLY=( $(compgen -W "$opts --help" -- $cur ) ) +fi + +if [[ "$prev" != "--help" ]]; +then + if [[ $argc = 2 ]]; + then + opts2=$(yunohost2 $prev -h | grep usage | awk -F"{" '{print $2}' | awk -F"}" '{print $1}' | tr ',' ' ') + COMPREPLY=( $(compgen -W "$opts2 --help" -- $cur ) ) + elif [[ $argc = 3 ]]; + then + COMPREPLY=( $(compgen -W "--help" $cur ) ) + fi +else + COMPREPLY=() +fi + +} +complete -F _yunohost yunohost