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.
102 lines
1.9 KiB
Bash
Executable File
102 lines
1.9 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
test_description='basic addto and list functionality
|
|
|
|
This test just makes sure the basic addto and listfile
|
|
commands work, including support for filtering.
|
|
'
|
|
. ./test-lib.sh
|
|
|
|
#
|
|
# Addto and listfile
|
|
#
|
|
test_todo_session 'nonexistant file' <<EOF
|
|
>>> todo.sh addto garden.txt notice the daisies
|
|
TODO: Destination file $HOME/garden.txt does not exist.
|
|
=== 1
|
|
EOF
|
|
|
|
touch "$HOME/garden.txt"
|
|
|
|
test_todo_session 'basic addto/listfile' <<EOF
|
|
>>> todo.sh addto garden.txt notice the daisies
|
|
1 notice the daisies
|
|
GARDEN: 1 added.
|
|
|
|
>>> todo.sh listfile garden.txt
|
|
1 notice the daisies
|
|
--
|
|
GARDEN: 1 of 1 tasks shown
|
|
|
|
>>> todo.sh addto garden.txt smell the roses
|
|
2 smell the roses
|
|
GARDEN: 2 added.
|
|
|
|
>>> todo.sh listfile garden.txt
|
|
1 notice the daisies
|
|
2 smell the roses
|
|
--
|
|
GARDEN: 2 of 2 tasks shown
|
|
EOF
|
|
|
|
#
|
|
# List available files
|
|
#
|
|
test_todo_session 'list available files' <<EOF
|
|
>>> todo.sh listfile
|
|
Files in the todo.txt directory:
|
|
done.txt
|
|
garden.txt
|
|
report.txt
|
|
todo.txt
|
|
|
|
>>> TODOTXT_VERBOSE=0 todo.sh listfile
|
|
done.txt
|
|
garden.txt
|
|
report.txt
|
|
todo.txt
|
|
EOF
|
|
|
|
#
|
|
# Filter
|
|
#
|
|
test_todo_session 'basic listfile filtering' <<EOF
|
|
>>> todo.sh listfile garden.txt daisies
|
|
1 notice the daisies
|
|
--
|
|
GARDEN: 1 of 2 tasks shown
|
|
|
|
>>> todo.sh listfile garden.txt smell
|
|
2 smell the roses
|
|
--
|
|
GARDEN: 1 of 2 tasks shown
|
|
EOF
|
|
|
|
test_todo_session 'case-insensitive filtering' <<EOF
|
|
>>> todo.sh addto garden.txt smell the uppercase Roses
|
|
3 smell the uppercase Roses
|
|
GARDEN: 3 added.
|
|
|
|
>>> todo.sh listfile garden.txt roses
|
|
2 smell the roses
|
|
3 smell the uppercase Roses
|
|
--
|
|
GARDEN: 2 of 3 tasks shown
|
|
EOF
|
|
|
|
test_todo_session 'addto with &' <<EOF
|
|
>>> todo.sh addto garden.txt "dig the garden & water the flowers"
|
|
4 dig the garden & water the flowers
|
|
GARDEN: 4 added.
|
|
|
|
>>> todo.sh listfile garden.txt
|
|
4 dig the garden & water the flowers
|
|
1 notice the daisies
|
|
2 smell the roses
|
|
3 smell the uppercase Roses
|
|
--
|
|
GARDEN: 4 of 4 tasks shown
|
|
EOF
|
|
|
|
test_done
|