ENH: Enable file completion for add-on actions via _todo_file{1,2,3}_actions (#270)
* Refactoring: Use regular expression match instead of case globbing for actions taking a SRC argument
Making it consistent with the test for MOVE_COMMAND_PATTERN, and allowing to extend the pattern with custom actions in the future.
* Refactoring: Move the anchoring and grouping out of MOVE_COMMAND_PATTERN
So that additional (custom) add-on actions can be configured in the future.
* ENH: Enable file completion for add-on actions via _todo_file{1,2,3}_actions
Allowing completion of todo files directly after the add-on action (1), with one (2) / two (3) arguments in between. This should handle most cases.
In order to configure the add-on completion, the corresponding configuration variable has to be defined in the user's shell (e.g. via ~/.bashrc):
_todo_file1_actions='myaction|anotheraction'
This commit is contained in:
28
tests/t6060-completion-addon-files.sh
Executable file
28
tests/t6060-completion-addon-files.sh
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/bash
|
||||
#
|
||||
|
||||
test_description='Bash add-on action file completion functionality
|
||||
|
||||
This test checks todo_completion of files for add-on actions that have file argument(s) configured
|
||||
'
|
||||
. ./test-lib.sh
|
||||
|
||||
readonly FILES='done.txt report.txt todo.txt'
|
||||
test_todo_completion 'nothing after unconfigured bar' 'todo.sh bar ' ''
|
||||
|
||||
_todo_file1_actions='foo|bar'
|
||||
test_todo_completion 'all files after configured bar' 'todo.sh bar ' "$FILES"
|
||||
test_todo_completion 'nothing after configured bar ITEM#' 'todo.sh bar 1 ' ''
|
||||
|
||||
_todo_file2_actions='baz'
|
||||
test_todo_completion 'nothing after configured baz' 'todo.sh baz ' ''
|
||||
test_todo_completion 'all files after configured baz ITEM#' 'todo.sh baz 1 ' "$FILES"
|
||||
test_todo_completion 'nothing after configured baz ITEM# MORE' 'todo.sh baz 1 more ' ''
|
||||
|
||||
_todo_file3_actions='biz'
|
||||
test_todo_completion 'nothing after configured biz' 'todo.sh biz ' ''
|
||||
test_todo_completion 'nothing after configured biz ITEM#' 'todo.sh biz 1 ' ''
|
||||
test_todo_completion 'all files after configured biz ITEM# MORE' 'todo.sh biz 1 more ' "$FILES"
|
||||
test_todo_completion 'nothing after configured biz ITEM# EVEN MORE' 'todo.sh biz 1 even more ' ''
|
||||
|
||||
test_done
|
||||
Reference in New Issue
Block a user