Permalink
Browse files

Add action argument for help to todo_completion.

Note that this is not perfect, as it only handles completing a single action after "help", but that should over the most important use case.
  • Loading branch information...
1 parent f2b9734 commit 7acb52119096c5e5a1615c477069561f9060da5c @inkarkat inkarkat committed Apr 27, 2012
Showing with 22 additions and 0 deletions.
  1. 0 tests/actions-test-lib.sh
  2. +20 −0 tests/t6100-completion-help.sh
  3. +2 −0 todo_completion
View
0 tests/actions-test-lib.sh 100755 → 100644
No changes.
@@ -0,0 +1,20 @@
+#!/bin/bash
+#
+
+test_description='Bash help completion functionality
+
+This test checks todo_completion of actions for usage help.
+'
+. ./actions-test-lib.sh
+. ./test-lib.sh
+make_action "zany"
+make_action "aardvark"
+
+readonly ACTIONS='add a addto addm append app archive command del rm depri dp do help list ls listaddons listall lsa listcon lsc listfile lf listpri lsp listproj lsprj move mv prepend prep pri p replace report shorthelp'
+readonly ADDONS='aardvark zany'
+
+test_todo_completion 'all actions after help' 'todo.sh help ' "$ACTIONS $ADDONS"
+test_todo_completion 'all actions after command help' 'todo.sh command help ' "$ACTIONS $ADDONS"
+test_todo_completion 'actions beginning with a' 'todo.sh help a' 'add a addto addm append app archive aardvark'
+
+test_done
View
@@ -28,6 +28,8 @@ _todo()
case "$prev" in
command)
completions=$COMMANDS;;
+ help)
+ completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons)";;
addto|listfile|lf)
completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listfile);;
-*) completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons) $OPTS";;

0 comments on commit 7acb521

Please sign in to comment.