From 879eac6d7636c159981a0bbc7e629c8b93740998 Mon Sep 17 00:00:00 2001 From: Vojtech Forejt Date: Thu, 20 Oct 2011 21:52:46 +0000 Subject: [PATCH] bash completion for property names git-svn-id: https://www.prismmodelchecker.org/svn/prism/prism/trunk@4098 bbc10eb1-c90d-0410-af57-cb519fbb1720 --- prism/etc/scripts/bash_prism_completion.sh | 30 ++++++++++------------ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/prism/etc/scripts/bash_prism_completion.sh b/prism/etc/scripts/bash_prism_completion.sh index 605ce739..3764b206 100644 --- a/prism/etc/scripts/bash_prism_completion.sh +++ b/prism/etc/scripts/bash_prism_completion.sh @@ -12,7 +12,6 @@ _prismcomplete() { cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - #TODO prev empty if [ "$prev" = -const ]; then #get the name of the model @@ -39,21 +38,20 @@ _prismcomplete() { return 0; fi; - #if [ "$prev" = -property ]; then - # - # PROPFILE=`echo $COMP_LINE | grep -o "[^ ]*[.]pctl" | sed "s/ ^//"` - # PROPFILE=`eval echo $PROPFILE` - # test -n "$PROPFILE"|| return 0; - # test -e $PROPFILE || return 0; - # - # #get the number of properties - # NUM=`sed "s/\/\/.*//" $PROPFILE | grep "[a-z]" | wc -l ` - # SEQUENCE=`seq 1 $NUM` - # - # COMPREPLY=( `compgen -W "$SEQUENCE" -- $cur` ) - # COMPREPLY=("${COMPREPLY[@]/%/ }") - # return 0; - #fi; + if [ "$prev" = -property ]; then + + PROPFILE=`echo $COMP_LINE | grep -E -o "[^ ]*[.](pctl|props)" | sed "s/ ^//"` + PROPFILE=`eval echo $PROPFILE` + test -n "$PROPFILE"|| return 0; + test -e $PROPFILE || return 0; + + #get the number of properties + SEQUENCE=`sed "s/\/\/.*//" $PROPFILE | grep "[a-z]" | awk '{print NR, " ", $0}' | sed "s/^[0-9]*[^\\"]*\\"\(.*\)\\":.*/\\1/" | sed "s/^\([0-9][0-9]*\).*$/\\1/"` + + COMPREPLY=( `compgen -W "$SEQUENCE" -- $cur` ) + COMPREPLY=("${COMPREPLY[@]/%/ }") + return 0; + fi; if [ "$prev" = -simmethod ]; then PARS="ci aci apmc sprt"