From 7acb52119096c5e5a1615c477069561f9060da5c Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Fri, 27 Apr 2012 14:29:29 +0200 Subject: [PATCH] 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. --- tests/actions-test-lib.sh | 0 tests/t6100-completion-help.sh | 20 ++++++++++++++++++++ todo_completion | 2 ++ 3 files changed, 22 insertions(+) mode change 100755 => 100644 tests/actions-test-lib.sh create mode 100755 tests/t6100-completion-help.sh diff --git a/tests/actions-test-lib.sh b/tests/actions-test-lib.sh old mode 100755 new mode 100644 diff --git a/tests/t6100-completion-help.sh b/tests/t6100-completion-help.sh new file mode 100755 index 0000000..079099f --- /dev/null +++ b/tests/t6100-completion-help.sh @@ -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 diff --git a/todo_completion b/todo_completion index 3f9d308..80abc68 100644 --- a/todo_completion +++ b/todo_completion @@ -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";;