* fix whitespace
* fix spelling
* fix whitespace
* unify headers of tests
* fix some issues in tests, identified by shellcheck
* fix bash completions
bash completion files are not supposed to be executable
* fix some issues identified by shellcheck
Co-authored-by: Ali Karbassi <ali@karbassi.com>
Before adding any more features to todo_completion, I feel like I need test coverage, so this is a first stab at testing the completion results, via a new test function test_todo_completion.
Some basic tests showcase the capabilities.
Note: test-lib.sh now uses arrays, therefore all tests must use /bin/bash, not /bin/sh to avoid errors when sourcing test-lib. For consistency with todo.sh, we should have used Bash everywhere, anyway. Also note that t2000-multiline.sh needs some more quoting to avoid "Bash: ambiguous redirect" errors.
This enhancement to todo_completion requires a small enhancement to the listfile action: When no SRC is specified, the list of text files in the todo.txt directory is printed. This is probably also useful on its own, and better than the original behavior of printing "TODO: File does not exist."
Note: I intentionally omitted bullet-proof error handling ($TODO_DIR non-existing or no text files contained), to avoid over-complicating this.
I.e. removed the colon after the ITEM#. Updated tasks are now listed like the 'todo.sh ls' command does, e.g.
42 smell the roses
This is in preparation to eventually use a function factored out from _list() for the verbose task output, which would enable coloring in the verbose message and thus align the verbose message output even more with the normal task output.
In verbose mode, commands first print the updated task, then summarize the change in the following line.
The add/addm/addto commands deviated from this, using "TODO: '<task>' added on line N."
This change splits this into two separate lines, obsoletes the implementation jargon of "line", and makes it easier to visually parse the message.
This is also a preparation for a possible future use of a _list()-like function, so that the updated task is processed and highlighted like the normal task output.
- _list() now shows the capitalized filename in place of 'TODO:'.
For example, listing garden.txt produces a output prefixed by 'GARDEN:'
This eliminates the ' from $FILE' part of the _list() output. All tests
were adjusted to match this new output.
- 'add' and 'addm' now 'addto' with $TODO_FILE instead of user supplied file
- 'addto' now shows the capitalized filename in place of 'TODO:'.
For example, adding to garden.txt produces a output prefixed by 'GARDEN:'
(Probably the most controversial part of this commit and up for
discussion. If kept, the 'listfile' output should be made to match.
Note that this convention would then minimize standard output by
dropping the file name.)
- All existing add/addm/add-date tests pass. Two new test sequences were
added to test 'addto' and 'listfile' functionality.
- A space/tab nuissance was cleared up in the tests/README file.