Factored out generation of custom action scripts.
- Reduced duplication via common make_action() function. - ENH: Adding proper shebang line to the custom action scripts. - Changed output of custom action to better differentiate from todo.sh output.
This commit is contained in:
@@ -8,10 +8,22 @@ This test covers the contract between todo.sh and custom actions.
|
||||
|
||||
unset TODO_ACTIONS_DIR
|
||||
mkdir .todo.actions.d
|
||||
cat > .todo.actions.d/foo << EOF
|
||||
echo "TODO: foo"
|
||||
make_action()
|
||||
{
|
||||
cat > ".todo.actions.d/$1" <<- EOF
|
||||
#!/bin/bash
|
||||
echo "custom action $1"
|
||||
EOF
|
||||
chmod +x ".todo.actions.d/$1"
|
||||
}
|
||||
|
||||
make_action "foo"
|
||||
test_todo_session 'executable action' <<EOF
|
||||
>>> todo.sh foo
|
||||
custom action foo
|
||||
EOF
|
||||
|
||||
chmod -x .todo.actions.d/foo
|
||||
test_todo_session 'nonexecutable action' <<EOF
|
||||
>>> todo.sh foo
|
||||
Usage: todo.sh [-fhpantvV] [-d todo_config] action [task_number] [task_description]
|
||||
@@ -19,33 +31,21 @@ Try 'todo.sh -h' for more information.
|
||||
=== 1
|
||||
EOF
|
||||
|
||||
chmod +x .todo.actions.d/foo
|
||||
test_todo_session 'executable action' <<EOF
|
||||
>>> todo.sh foo
|
||||
TODO: foo
|
||||
EOF
|
||||
|
||||
cat > .todo.actions.d/ls << EOF
|
||||
echo "TODO: my ls"
|
||||
EOF
|
||||
chmod +x .todo.actions.d/ls
|
||||
make_action "ls"
|
||||
test_todo_session 'overriding built-in action' <<EOF
|
||||
>>> todo.sh ls
|
||||
TODO: my ls
|
||||
custom action ls
|
||||
|
||||
>>> todo.sh command ls
|
||||
--
|
||||
TODO: 0 of 0 tasks shown
|
||||
EOF
|
||||
|
||||
cat > .todo.actions.d/bad << EOF
|
||||
echo "TODO: bad"
|
||||
exit 42
|
||||
EOF
|
||||
chmod +x .todo.actions.d/bad
|
||||
make_action "bad"
|
||||
echo "exit 42" >> .todo.actions.d/bad
|
||||
test_todo_session 'failing action' <<EOF
|
||||
>>> todo.sh bad
|
||||
TODO: bad
|
||||
custom action bad
|
||||
=== 42
|
||||
EOF
|
||||
|
||||
|
||||
Reference in New Issue
Block a user