Compare commits
17 Commits
archive/co
...
archive/co
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3b0309d9bc | ||
|
|
b21d16878f | ||
|
|
3e82f3ca56 | ||
|
|
ebe6a403c8 | ||
|
|
a6fed991e5 | ||
|
|
94f770926b | ||
|
|
322f3075d2 | ||
|
|
bc81db2f2b | ||
|
|
6259cdb6da | ||
|
|
f76b6d5210 | ||
|
|
c1ad7f3560 | ||
|
|
a777b266ed | ||
|
|
ebce735d04 | ||
|
|
e5a308eb03 | ||
|
|
e600a2162b | ||
|
|
3d0a4d0b30 | ||
|
|
79f428779c |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,3 +1,6 @@
|
|||||||
VERSION-FILE
|
VERSION-FILE
|
||||||
tests/test-results
|
tests/test-results
|
||||||
tests/trash\ directory.*
|
tests/trash\ directory.*
|
||||||
|
done.txt
|
||||||
|
report.txt
|
||||||
|
todo.txt
|
||||||
|
|||||||
@@ -9,8 +9,15 @@ On failure, it will print each offending line number and line.
|
|||||||
'
|
'
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
backtick_check()
|
||||||
|
{
|
||||||
|
sed -n -e 's/\(^\|[ \t]\)#.*//' -e '/`/{' -e '=;p' -e '}' "$@"
|
||||||
|
}
|
||||||
|
|
||||||
test_todo_session 'no old-style backtick command substitution' <<EOF
|
test_todo_session 'no old-style backtick command substitution' <<EOF
|
||||||
>>> sed -n -e 's/\(^\|[ \t]\)#.*//' -e '/\`/{' -e '=;p' -e '}' "$(which todo.sh)"
|
>>> backtick_check bin/todo.sh
|
||||||
|
|
||||||
|
>>> backtick_check ../../todo.cfg
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ This test checks basic todo_completion of actions and options
|
|||||||
'
|
'
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
readonly ACTIONS='add a addto addm append app archive command del rm depri dp do help list ls listall lsa listcon lsc listfile lf listpri lsp listproj lsprj move mv prepend prep pri p replace report shorthelp'
|
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 OPTIONS='-@ -@@ -+ -++ -d -f -h -p -P -PP -a -n -t -v -vv -V -x'
|
readonly OPTIONS='-@ -@@ -+ -++ -d -f -h -p -P -PP -a -n -t -v -vv -V -x'
|
||||||
|
|
||||||
test_todo_completion 'all arguments' 'todo.sh ' "$ACTIONS $OPTIONS"
|
test_todo_completion 'all arguments' 'todo.sh ' "$ACTIONS $OPTIONS"
|
||||||
|
|||||||
@@ -7,20 +7,68 @@ This test checks todo_completion of custom actions in .todo.actions.d
|
|||||||
'
|
'
|
||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
readonly ACTIONS='add a addto addm append app archive command del rm depri dp do help list ls listall lsa listcon lsc listfile lf listpri lsp listproj lsprj move mv prepend prep pri p replace report shorthelp'
|
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 OPTIONS='-@ -@@ -+ -++ -d -f -h -p -P -PP -a -n -t -v -vv -V -x'
|
readonly OPTIONS='-@ -@@ -+ -++ -d -f -h -p -P -PP -a -n -t -v -vv -V -x'
|
||||||
|
|
||||||
readonly ADDONS='bar baz foobar'
|
readonly ADDONS='bar baz foobar'
|
||||||
mkdir "$HOME/.todo.actions.d"
|
makeCustomActions()
|
||||||
|
{
|
||||||
|
set -e
|
||||||
|
mkdir "${1:?}"
|
||||||
for addon in $ADDONS
|
for addon in $ADDONS
|
||||||
do
|
do
|
||||||
> "$HOME/.todo.actions.d/$addon"
|
addonFile="${1}/$addon"
|
||||||
chmod +x "$HOME/.todo.actions.d/$addon"
|
> "$addonFile"
|
||||||
|
chmod +x "$addonFile"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Also create a subdirectory, to test that it is skipped.
|
||||||
|
mkdir "${1}/subdir"
|
||||||
|
|
||||||
|
# Also create a non-executable file, to test that it is skipped.
|
||||||
|
datafile="${1:?}/datafile"
|
||||||
|
> "$datafile"
|
||||||
|
chmod -x "$datafile"
|
||||||
|
[ -x "$datafile" ] && rm "$datafile" # Some file systems may always make files executable; then, skip this check.
|
||||||
|
|
||||||
|
set +e
|
||||||
|
}
|
||||||
|
removeCustomActions()
|
||||||
|
{
|
||||||
|
set -e
|
||||||
|
rmdir "${1}/subdir"
|
||||||
|
rm "${1:?}/"*
|
||||||
|
rmdir "$1"
|
||||||
|
set +e
|
||||||
|
}
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test resolution of the default TODO_ACTIONS_DIR.
|
||||||
|
#
|
||||||
|
makeCustomActions "$HOME/.todo.actions.d"
|
||||||
test_todo_completion 'all arguments' 'todo.sh ' "$ACTIONS $ADDONS $OPTIONS"
|
test_todo_completion 'all arguments' 'todo.sh ' "$ACTIONS $ADDONS $OPTIONS"
|
||||||
test_todo_completion 'all arguments after option' 'todo.sh -a ' "$ACTIONS $ADDONS $OPTIONS"
|
test_todo_completion 'all arguments after option' 'todo.sh -a ' "$ACTIONS $ADDONS $OPTIONS"
|
||||||
test_todo_completion 'all arguments beginning with b' 'todo.sh b' 'bar baz'
|
test_todo_completion 'all arguments beginning with b' 'todo.sh b' 'bar baz'
|
||||||
test_todo_completion 'all arguments beginning with f after options' 'todo.sh -a -v f' 'foobar'
|
test_todo_completion 'all arguments beginning with f after options' 'todo.sh -a -v f' 'foobar'
|
||||||
test_todo_completion 'nothing after addon action' 'todo.sh foobar ' ''
|
test_todo_completion 'nothing after addon action' 'todo.sh foobar ' ''
|
||||||
|
removeCustomActions "$HOME/.todo.actions.d"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test resolution of an alternative TODO_ACTIONS_DIR.
|
||||||
|
#
|
||||||
|
mkdir "$HOME/.todo"
|
||||||
|
makeCustomActions "$HOME/.todo/actions"
|
||||||
|
test_todo_completion 'all arguments with actions from .todo/actions/' 'todo.sh ' "$ACTIONS $ADDONS $OPTIONS"
|
||||||
|
removeCustomActions "$HOME/.todo/actions"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Test resolution of a configured TODO_ACTIONS_DIR.
|
||||||
|
#
|
||||||
|
makeCustomActions "$HOME/addons"
|
||||||
|
cat >> todo.cfg <<'EOF'
|
||||||
|
export TODO_ACTIONS_DIR="$HOME/addons"
|
||||||
|
EOF
|
||||||
|
test_todo_completion 'all arguments with actions from addons/' 'todo.sh ' "$ACTIONS $ADDONS $OPTIONS"
|
||||||
|
removeCustomActions "$HOME/addons"
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
|||||||
2
todo.cfg
2
todo.cfg
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
# Your todo.txt directory
|
# Your todo.txt directory
|
||||||
#export TODO_DIR="/Users/gina/Documents/todo"
|
#export TODO_DIR="/Users/gina/Documents/todo"
|
||||||
export TODO_DIR=`dirname "$0"`
|
export TODO_DIR=$(dirname "$0")
|
||||||
|
|
||||||
# Your todo/done/report.txt locations
|
# Your todo/done/report.txt locations
|
||||||
export TODO_FILE="$TODO_DIR/todo.txt"
|
export TODO_FILE="$TODO_DIR/todo.txt"
|
||||||
|
|||||||
16
todo.sh
16
todo.sh
@@ -57,6 +57,7 @@ shorthelp()
|
|||||||
help
|
help
|
||||||
list|ls [TERM...]
|
list|ls [TERM...]
|
||||||
listall|lsa [TERM...]
|
listall|lsa [TERM...]
|
||||||
|
listaddons
|
||||||
listcon|lsc
|
listcon|lsc
|
||||||
listfile|lf [SRC [TERM...]]
|
listfile|lf [SRC [TERM...]]
|
||||||
listpri|lsp [PRIORITIES] [TERM...]
|
listpri|lsp [PRIORITIES] [TERM...]
|
||||||
@@ -219,6 +220,9 @@ help()
|
|||||||
TERM specified, lists entire todo.txt AND done.txt
|
TERM specified, lists entire todo.txt AND done.txt
|
||||||
concatenated and sorted.
|
concatenated and sorted.
|
||||||
|
|
||||||
|
listaddons
|
||||||
|
Lists all added and overridden actions in the actions directory.
|
||||||
|
|
||||||
listcon
|
listcon
|
||||||
lsc
|
lsc
|
||||||
Lists all the task contexts that start with the @ sign in todo.txt.
|
Lists all the task contexts that start with the @ sign in todo.txt.
|
||||||
@@ -1300,6 +1304,18 @@ note: PRIORITY must be anywhere from A to Z."
|
|||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
"listaddons" )
|
||||||
|
if [ -d "$TODO_ACTIONS_DIR" ]; then
|
||||||
|
cd "$TODO_ACTIONS_DIR" || exit $?
|
||||||
|
for action in *
|
||||||
|
do
|
||||||
|
if [ -f "$action" -a -x "$action" ]; then
|
||||||
|
echo "$action"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
|
||||||
* )
|
* )
|
||||||
usage;;
|
usage;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -11,18 +11,14 @@ _todo()
|
|||||||
local -r OPTS="-@ -@@ -+ -++ -d -f -h -p -P -PP -a -n -t -v -vv -V -x"
|
local -r OPTS="-@ -@@ -+ -++ -d -f -h -p -P -PP -a -n -t -v -vv -V -x"
|
||||||
local -r COMMANDS="\
|
local -r COMMANDS="\
|
||||||
add a addto addm append app archive command del \
|
add a addto addm append app archive command del \
|
||||||
rm depri dp do help list ls listall lsa listcon \
|
rm depri dp do help list ls listaddons listall lsa listcon \
|
||||||
lsc listfile lf listpri lsp listproj lsprj move \
|
lsc listfile lf listpri lsp listproj lsprj move \
|
||||||
mv prepend prep pri p replace report shorthelp"
|
mv prepend prep pri p replace report shorthelp"
|
||||||
|
|
||||||
# Add custom commands from add-ons, if installed.
|
|
||||||
# TODO: Filter for executable flag of files found in $TODO_ACTIONS_DIR.
|
|
||||||
local allCommands="$COMMANDS $('ls' "${TODO_ACTIONS_DIR:-$HOME/.todo.actions.d}/" 2>/dev/null)"
|
|
||||||
|
|
||||||
local _todo_sh=${_todo_sh:-todo.sh}
|
local _todo_sh=${_todo_sh:-todo.sh}
|
||||||
local completions
|
local completions
|
||||||
if [ $COMP_CWORD -eq 1 ]; then
|
if [ $COMP_CWORD -eq 1 ]; then
|
||||||
completions="$allCommands $OPTS"
|
completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons) $OPTS"
|
||||||
elif [[ $COMP_CWORD -gt 2 && ( \
|
elif [[ $COMP_CWORD -gt 2 && ( \
|
||||||
"${COMP_WORDS[COMP_CWORD-2]}" =~ ^(move|mv)$ || \
|
"${COMP_WORDS[COMP_CWORD-2]}" =~ ^(move|mv)$ || \
|
||||||
"${COMP_WORDS[COMP_CWORD-3]}" =~ ^(move|mv)$ ) ]]; then
|
"${COMP_WORDS[COMP_CWORD-3]}" =~ ^(move|mv)$ ) ]]; then
|
||||||
@@ -34,7 +30,7 @@ _todo()
|
|||||||
completions=$COMMANDS;;
|
completions=$COMMANDS;;
|
||||||
addto|listfile|lf)
|
addto|listfile|lf)
|
||||||
completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listfile);;
|
completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listfile);;
|
||||||
-*) completions="$allCommands $OPTS";;
|
-*) completions="$COMMANDS $(eval TODOTXT_VERBOSE=0 $_todo_sh command listaddons) $OPTS";;
|
||||||
*) case "$cur" in
|
*) case "$cur" in
|
||||||
+*) completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listproj)
|
+*) completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listproj)
|
||||||
COMPREPLY=( $( compgen -W "$completions" -- $cur ))
|
COMPREPLY=( $( compgen -W "$completions" -- $cur ))
|
||||||
@@ -62,7 +58,7 @@ _todo()
|
|||||||
# a safety check of the ls action output.
|
# a safety check of the ls action output.
|
||||||
local todo=$( \
|
local todo=$( \
|
||||||
eval TODOTXT_VERBOSE=0 $_todo_sh '-@ -+ -p -x command ls "^ *${cur} "' | \
|
eval TODOTXT_VERBOSE=0 $_todo_sh '-@ -+ -p -x command ls "^ *${cur} "' | \
|
||||||
sed -e 's/^ *[0-9]\+ //' -e 's/\((.) \)[0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} /\1/' \
|
sed -e 's/^ *[0-9]\{1,\} //' -e 's/\((.) \)[0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} /\1/' \
|
||||||
-e 's/\([xX] \)\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{1,2\}/\1/' \
|
-e 's/\([xX] \)\([0-9]\{2,4\}-[0-9]\{2\}-[0-9]\{2\} \)\{1,2\}/\1/' \
|
||||||
-e 's/[[:space:]]*$//' \
|
-e 's/[[:space:]]*$//' \
|
||||||
-e '1q' \
|
-e '1q' \
|
||||||
|
|||||||
Reference in New Issue
Block a user