From cd470d4d622640a6b1a4d84082e3107ca44a16a4 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Sun, 14 Oct 2012 11:14:59 +0200 Subject: o Improved completion after refactoring, not done yet. --- app_completion | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'app_completion') diff --git a/app_completion b/app_completion index 62050fd..68a3b7b 100644 --- a/app_completion +++ b/app_completion @@ -6,13 +6,9 @@ _appsh_contains() { } _appsh_methods=( + "app" "conf" - "install" - "list" - "list-versions" - "set-current" - "start" - "stop" + "operate" ) _appsh_parse_opts() { @@ -32,49 +28,53 @@ _appsh_parse_opts() { prev="${COMP_WORDS[$i]}" done echo "local has_method='$has_method'" + + case "${COMP_WORDS[COMP_CWORD]}" in + -*) + echo "local in_option=yes" + ;; + esac } _complete_appsh() { COMPREPLY=() local cur="${COMP_WORDS[COMP_CWORD]}" local prev="${COMP_WORDS[COMP_CWORD-1]}" - local opts + local opts="" eval `_appsh_parse_opts` if [ $COMP_CWORD == 1 ] then opts="${_appsh_methods[@]}" + opts="$opts" + if [ "$in_option" = "yes" ] + then opts="-n $opts" + fi COMPREPLY=($(compgen -W "${opts}" -- ${cur})) return 0 fi case $prev in -n) - values=$(./app list -P name) + values=$(./app app list -P name) COMPREPLY=($(compgen -W "$values" -- ${cur})) return 0 ;; -i) if [ -n "$has_n" ] then - values=$(./app list -n $has_n -P instance) + values=$(./app app list -n $has_n -P instance) COMPREPLY=($(compgen -W "$values" -- ${cur})) return 0 fi ;; esac - opts="" - if [ -z "$has_n" ] + if [ -n "$has_n" -a -z "$has_i" ] then - opts="$opts -n" - else - if [ -z "$has_i" ] - then - opts="$opts -i" - fi + opts="$opts -i" fi if [ -z "$has_method" ] -- cgit v1.2.3