[ditz-talk] [PATCH] bash completion: support commandline options

Christian Garbs mitch at cgarbs.de
Fri Aug 29 16:51:48 EDT 2008


add support for --comment, --no-comment and --silent where applicable
---
 ...e-b3468b77d26514af3c7667f0d644b3f38f9e29f0.yaml |    8 +++++-
 contrib/completion/ditz.bash                       |   21 +++++++++++++++++++-
 2 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/bugs/issue-b3468b77d26514af3c7667f0d644b3f38f9e29f0.yaml b/bugs/issue-b3468b77d26514af3c7667f0d644b3f38f9e29f0.yaml
index 6989b8a..8015766 100644
--- a/bugs/issue-b3468b77d26514af3c7667f0d644b3f38f9e29f0.yaml
+++ b/bugs/issue-b3468b77d26514af3c7667f0d644b3f38f9e29f0.yaml
@@ -5,8 +5,8 @@ type: :task
 component: ditz
 release: "0.6"
 reporter: Christian Garbs <mitch at cgarbs.de>
-status: :in_progress
-disposition: 
+status: :closed
+disposition: :fixed
 creation_time: 2008-08-22 12:19:45.501116 Z
 references: []
 
@@ -20,5 +20,9 @@ log_events:
   - Christian Garbs <mitch at cgarbs.de>
   - changed status from unstarted to in_progress
   - ""
+- - 2008-08-29 20:40:26.189706 Z
+  - Christian Garbs <mitch at cgarbs.de>
+  - closed with disposition fixed
+  - fixed, also enabled --silent for the edit command
 git_branch: 
 claimer: 
diff --git a/contrib/completion/ditz.bash b/contrib/completion/ditz.bash
index 89f047f..1bbdf43 100644
--- a/contrib/completion/ditz.bash
+++ b/contrib/completion/ditz.bash
@@ -7,12 +7,31 @@
 _ditz() 
 {
     local cur=${COMP_WORDS[COMP_CWORD]}
+
     if [ $COMP_CWORD -eq 1 ]; then
+	# no command yet, show all commands
 	COMPREPLY=( $( compgen -W "$(ditz --commands)" -- $cur ) )
+
     else
 	unset COMP_WORDS[COMP_CWORD]  # remove last
 	unset COMP_WORDS[0]           # remove first
-	COMPREPLY=( $( compgen -W "$(ditz "${COMP_WORDS[@]}" '<options>' 2>/dev/null)" -- $cur ) )
+	
+	# add options if applicable...
+	local options
+	if [ "${cur:0:1}" = '-' ]; then
+	    # ...but only if at least a dash is given
+	    case "${COMP_WORDS[1]}" in
+		add|add_reference|add_release|assign|close|comment|release|set_component|start|stop|unassign)
+		    options="--comment --no-comment"
+		    ;;
+		edit)
+		    options="--comment --no-comment --silent"
+		    ;;
+	    esac
+	fi
+	
+	# let ditz parse the commandline and print available completions, then append the options form above
+	COMPREPLY=( $( compgen -W "$(ditz "${COMP_WORDS[@]}" '<options>' 2>/dev/null) $options" -- $cur ) )
     fi 
 }
 
-- 
1.5.6.3




More information about the ditz-talk mailing list