diff --git a/README.md b/README.md index 2601c7d9..67e15542 100644 --- a/README.md +++ b/README.md @@ -74,10 +74,10 @@ For example, to add a todo item, you can do: todo.sh add "THING I NEED TO DO +project @context" ``` ### `replace` -Replaces task on line ITEM# with UPDATED TODO. +Replaces task on line NR with UPDATED TODO. ```shell -todo.sh replace ITEM# "UPDATED TODO" +todo.sh replace NR "UPDATED TODO" ``` ### `report` Adds the number of open tasks and done tasks to report.txt. diff --git a/USAGE.md b/USAGE.md index 4500377b..b6b4f0f7 100644 --- a/USAGE.md +++ b/USAGE.md @@ -38,13 +38,13 @@ todo.sh addto DEST "TEXT TO ADD" ``` ### `append` -Adds TEXT TO APPEND to the end of the task on line ITEM#. +Adds TEXT TO APPEND to the end of the task on line NR. Quotes optional. ```shell -todo.sh append ITEM# "TEXT TO APPEND" -todo.sh app ITEM# "TEXT TO APPEND" +todo.sh append NR "TEXT TO APPEND" +todo.sh app NR "TEXT TO APPEND" ``` ### `archive` @@ -71,26 +71,26 @@ todo.sh deduplicate ``` ### `del` -Deletes the task on line ITEM# in todo.txt. If TERM specified, deletes only TERM from the task. +Deletes the task on line NR in todo.txt. If TERM specified, deletes only TERM from the task. ```shell -todo.sh del ITEM# [TERM] -todo.sh rm ITEM# [TERM] +todo.sh del NR [TERM] +todo.sh rm NR [TERM] ``` ### `depri` -Deprioritizes (removes the priority) from the task(s) on line ITEM# in todo.txt. +Deprioritizes (removes the priority) from the task(s) on line NR in todo.txt. ```shell -todo.sh depri ITEM#[, ITEM#, ITEM#, ...] -todo.sh dp ITEM#[, ITEM#, ITEM#, ...] +todo.sh depri NR [NR ...] +todo.sh dp NR [NR ...] ``` ### `do` -Marks task(s) on line ITEM# as done in todo.txt. +Marks task(s) on line NR as done in todo.txt. ```shell -todo.sh do ITEM#[, ITEM#, ITEM#, ...] +todo.sh do NR [NR ...] ``` ### `help` @@ -164,34 +164,34 @@ todo.sh lsprj [TERM...] ``` ### `move` -Moves a line from source text file (SRC) to destination text file (DEST). Both source and destination file must be located in the directory defined in the configuration directory. When SRC is not defined it's by default todo.txt. +Moves line NR from source text file (SRC) to destination text file (DEST). Both source and destination file must be located in the directory defined in the configuration directory. When SRC is not defined it's by default todo.txt. ```shell -todo.sh move ITEM# DEST [SRC] -todo.sh mv ITEM# DEST [SRC] +todo.sh move NR DEST [SRC] +todo.sh mv NR DEST [SRC] ``` ### `prepend` -Adds TEXT TO PREPEND to the beginning of the task on line ITEM#. Quotes optional. +Adds TEXT TO PREPEND to the beginning of the task on line NR. Quotes optional. ```shell -todo.sh prepend ITEM# "TEXT TO PREPEND" -todo.sh prep ITEM# "TEXT TO PREPEND" +todo.sh prepend NR "TEXT TO PREPEND" +todo.sh prep NR"TEXT TO PREPEND" ``` ### `pri` -Adds PRIORITY to task on line ITEM#. If the task is already prioritized, replaces current priority with new PRIORITY. PRIORITY must be a letter between A and Z. +Adds PRIORITY to task on line NR. If the task is already prioritized, replaces current priority with new PRIORITY. PRIORITY must be a letter between A and Z. ```shell -todo.sh pri ITEM# PRIORITY -todo.sh p ITEM# PRIORITY +todo.sh pri NR PRIORITY +todo.sh p NR PRIORITY ``` ### `replace` -Replaces task on line ITEM# with UPDATED TODO. +Replaces task on line NR with UPDATED TODO. ```shell -todo.sh replace ITEM# "UPDATED TODO" +todo.sh replace NR "UPDATED TODO" ``` ### `report` diff --git a/tests/actions-test-lib.sh b/tests/actions-test-lib.sh index 541babb3..e3cfe232 100644 --- a/tests/actions-test-lib.sh +++ b/tests/actions-test-lib.sh @@ -6,7 +6,7 @@ make_dummy_action() cat > "$1" < /dev/null test_todo_session 'replace usage' <>> todo.sh replace adf asdfa === 1 -usage: todo.sh replace ITEM# "UPDATED ITEM" +usage: todo.sh replace NR "UPDATED ITEM" EOF test_todo_session 'basic replace' <>> todo.sh pri B B -usage: todo.sh pri ITEM# PRIORITY[, ITEM# PRIORITY, ...] +usage: todo.sh pri NR PRIORITY [NR PRIORITY ...] note: PRIORITY must be anywhere from A to Z. === 1 EOF diff --git a/tests/t1400-prepend.sh b/tests/t1400-prepend.sh index c45a04ae..4d6adc0e 100755 --- a/tests/t1400-prepend.sh +++ b/tests/t1400-prepend.sh @@ -6,7 +6,7 @@ test_description='basic prepend functionality test_todo_session 'prepend usage' <>> todo.sh prepend B B -usage: todo.sh prepend ITEM# "TEXT TO PREPEND" +usage: todo.sh prepend NR "TEXT TO PREPEND" === 1 EOF diff --git a/tests/t1500-do.sh b/tests/t1500-do.sh index 20b2bccf..6ee2c48a 100755 --- a/tests/t1500-do.sh +++ b/tests/t1500-do.sh @@ -8,13 +8,13 @@ test_description='do functionality test_todo_session 'do usage' <>> todo.sh do B B -usage: todo.sh do ITEM#[, ITEM#, ITEM#, ...] +usage: todo.sh do NR [NR ...] === 1 EOF -test_todo_session 'do missing ITEM#' <>> todo.sh do -usage: todo.sh do ITEM#[, ITEM#, ITEM#, ...] +usage: todo.sh do NR [NR ...] === 1 EOF diff --git a/tests/t1600-append.sh b/tests/t1600-append.sh index 0d350882..626d1f4c 100755 --- a/tests/t1600-append.sh +++ b/tests/t1600-append.sh @@ -14,7 +14,7 @@ todo.sh add notice the daisies > /dev/null test_todo_session 'append usage' <>> todo.sh append adf asdfa === 1 -usage: todo.sh append ITEM# "TEXT TO APPEND" +usage: todo.sh append NR "TEXT TO APPEND" EOF test_todo_session 'append error' <>> todo.sh depri B B -usage: todo.sh depri ITEM#[, ITEM#, ITEM#, ...] +usage: todo.sh depri NR [NR ...] === 1 EOF diff --git a/tests/t1800-del.sh b/tests/t1800-del.sh index b9058ce5..970afe08 100755 --- a/tests/t1800-del.sh +++ b/tests/t1800-del.sh @@ -8,7 +8,7 @@ SPACE=' ' test_todo_session 'del usage' <>> todo.sh del B -usage: todo.sh del ITEM# [TERM] +usage: todo.sh del NR [TERM] === 1 EOF diff --git a/tests/t2110-help-action.sh b/tests/t2110-help-action.sh index ada2047b..f31de714 100755 --- a/tests/t2110-help-action.sh +++ b/tests/t2110-help-action.sh @@ -32,24 +32,24 @@ test_todo_session 'multiple actions help' <<'EOF' shorthelp List the one-line usage of all built-in and add-on actions. \ - append ITEM# "TEXT TO APPEND" - app ITEM# "TEXT TO APPEND" - Adds TEXT TO APPEND to the end of the task on line ITEM#. + append NR "TEXT TO APPEND" + app NR "TEXT TO APPEND" + Adds TEXT TO APPEND to the end of the task on line NR. Quotes optional. \ EOF test_todo_session 'short and long form of action help' <<'EOF' >>> todo.sh help append - append ITEM# "TEXT TO APPEND" - app ITEM# "TEXT TO APPEND" - Adds TEXT TO APPEND to the end of the task on line ITEM#. + append NR "TEXT TO APPEND" + app NR "TEXT TO APPEND" + Adds TEXT TO APPEND to the end of the task on line NR. Quotes optional. \ >>> todo.sh help app - app ITEM# "TEXT TO APPEND" - Adds TEXT TO APPEND to the end of the task on line ITEM#. + app NR "TEXT TO APPEND" + Adds TEXT TO APPEND to the end of the task on line NR. Quotes optional. \ EOF diff --git a/tests/t6040-completion-files.sh b/tests/t6040-completion-files.sh index 959abf60..aae89958 100755 --- a/tests/t6040-completion-files.sh +++ b/tests/t6040-completion-files.sh @@ -13,8 +13,8 @@ test_todo_completion 'files beginning with d after addto' 'todo.sh addto d' 'don test_todo_completion 'all files after listfile' 'todo.sh listfile ' "$FILES" test_todo_completion 'all files after lf' 'todo.sh -v lf ' "$FILES" test_todo_completion 'nothing after move' 'todo.sh move ' '' -test_todo_completion 'all files after move ITEM#' 'todo.sh move 1 ' "$FILES" -test_todo_completion 'all files after mv ITEM#' 'todo.sh mv 1 ' "$FILES" -test_todo_completion 'all files after move ITEM# DEST' 'todo.sh move 1 todo.sh ' "$FILES" +test_todo_completion 'all files after move NR' 'todo.sh move 1 ' "$FILES" +test_todo_completion 'all files after mv NR' 'todo.sh mv 1 ' "$FILES" +test_todo_completion 'all files after move NR DEST' 'todo.sh move 1 todo.sh ' "$FILES" test_done diff --git a/tests/t6060-completion-addon-files.sh b/tests/t6060-completion-addon-files.sh index eb14e0d4..07f19713 100755 --- a/tests/t6060-completion-addon-files.sh +++ b/tests/t6060-completion-addon-files.sh @@ -11,17 +11,17 @@ 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 ' '' +test_todo_completion 'nothing after configured bar NR' '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 ' '' +test_todo_completion 'all files after configured baz NR' 'todo.sh baz 1 ' "$FILES" +test_todo_completion 'nothing after configured baz NR 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_todo_completion 'nothing after configured biz NR' 'todo.sh biz 1 ' '' +test_todo_completion 'all files after configured biz NR MORE' 'todo.sh biz 1 more ' "$FILES" +test_todo_completion 'nothing after configured biz NR EVEN MORE' 'todo.sh biz 1 even more ' '' test_done diff --git a/tests/t8020-actions-help.sh b/tests/t8020-actions-help.sh index 449f46e8..09151169 100755 --- a/tests/t8020-actions-help.sh +++ b/tests/t8020-actions-help.sh @@ -20,22 +20,22 @@ make_action "quux" test_todo_session 'custom action help' <<'EOF' >>> todo.sh help foo - foo ITEM#[, ITEM#, ...] [TERM...] + foo NR [NR ...] [TERM...] This custom action does foo. \ >>> todo.sh help bar - bar ITEM#[, ITEM#, ...] [TERM...] + bar NR [NR ...] [TERM...] This custom action does bar. \ EOF test_todo_session 'multiple custom actions help' <<'EOF' >>> todo.sh help foo bar - foo ITEM#[, ITEM#, ...] [TERM...] + foo NR [NR ...] [TERM...] This custom action does foo. \ - bar ITEM#[, ITEM#, ...] [TERM...] + bar NR [NR ...] [TERM...] This custom action does bar. \ EOF @@ -46,7 +46,7 @@ TODO: No action "doesnotexist" exists. === 1 >>> todo.sh help foo doesnotexist bar - foo ITEM#[, ITEM#, ...] [TERM...] + foo NR [NR ...] [TERM...] This custom action does foo. \ TODO: No action "doesnotexist" exists. @@ -55,20 +55,20 @@ EOF test_todo_session 'mixed built-in and custom actions help' <<'EOF' >>> todo.sh help foo shorthelp bar - foo ITEM#[, ITEM#, ...] [TERM...] + foo NR [NR ...] [TERM...] This custom action does foo. \ shorthelp List the one-line usage of all built-in and add-on actions. \ - bar ITEM#[, ITEM#, ...] [TERM...] + bar NR [NR ...] [TERM...] This custom action does bar. \ EOF test_todo_session 'custom override of built-in action help' <<'EOF' >>> todo.sh help ls - ls ITEM#[, ITEM#, ...] [TERM...] + ls NR [NR ...] [TERM...] This custom action does ls. \ EOF diff --git a/tests/t9999-testsuite_example.sh b/tests/t9999-testsuite_example.sh index 0228fc99..cdc7a901 100755 --- a/tests/t9999-testsuite_example.sh +++ b/tests/t9999-testsuite_example.sh @@ -90,7 +90,7 @@ TODO: $HOME/todo.txt archived. TODO: Report file updated. >>> todo.sh append g a -usage: todo.sh append ITEM# "TEXT TO APPEND" +usage: todo.sh append NR "TEXT TO APPEND" === 1 >>> todo.sh append 2 and think diff --git a/todo.sh b/todo.sh index 34b9c60f..fa4601a6 100755 --- a/todo.sh +++ b/todo.sh @@ -45,13 +45,13 @@ shorthelp() addm "THINGS I NEED TO DO MORE THINGS I NEED TO DO" addto DEST "TEXT TO ADD" - append|app ITEM# "TEXT TO APPEND" + append|app NR "TEXT TO APPEND" archive command [ACTIONS] deduplicate - del|rm ITEM# [TERM] - depri|dp ITEM#[, ITEM#, ITEM#, ...] - done|do ITEM#[, ITEM#, ITEM#, ...] + del|rm NR [TERM] + depri|dp NR [NR ...] + done|do NR [NR ...] help [ACTION...] list|ls [TERM...] listall|lsa [TERM...] @@ -60,10 +60,10 @@ shorthelp() listfile|lf [SRC [TERM...]] listpri|lsp [PRIORITIES] [TERM...] listproj|lsprj [TERM...] - move|mv ITEM# DEST [SRC] - prepend|prep ITEM# "TEXT TO PREPEND" - pri|p ITEM# PRIORITY[, ITEM# PRIORITY, ...] - replace ITEM# "UPDATED TODO" + move|mv NR DEST [SRC] + prepend|prep NR "TEXT TO PREPEND" + pri|p NR PRIORITY [NR PRIORITY ...] + replace NR "UPDATED TODO" report shorthelp @@ -180,9 +180,9 @@ actionsHelp() Adds a line of text to any file located in the todo.txt directory. For example, addto inbox.txt "decide about vacation" - append ITEM# "TEXT TO APPEND" - app ITEM# "TEXT TO APPEND" - Adds TEXT TO APPEND to the end of the task on line ITEM#. + append NR "TEXT TO APPEND" + app NR "TEXT TO APPEND" + Adds TEXT TO APPEND to the end of the task on line NR. Quotes optional. archive @@ -195,19 +195,19 @@ actionsHelp() deduplicate Removes duplicate lines from todo.txt. - del ITEM# [TERM] - rm ITEM# [TERM] - Deletes the task on line ITEM# in todo.txt. + del NR [TERM] + rm NR [TERM] + Deletes the task on line NR in todo.txt. If TERM specified, deletes only TERM from the task. - depri ITEM#[, ITEM#, ITEM#, ...] - dp ITEM#[, ITEM#, ITEM#, ...] + depri NR [NR ...] + dp NR [NR ...] Deprioritizes (removes the priority) from the task(s) - on line ITEM# in todo.txt. + on line NR in todo.txt. - done ITEM#[, ITEM#, ITEM#, ...] - do ITEM#[, ITEM#, ITEM#, ...] - Marks task(s) on line ITEM# as done in todo.txt. + done NR [NR ...] + do NR [NR ...] + Marks task(s) on line NR as done in todo.txt. help [ACTION...] Display help about usage, options, built-in and add-on actions, @@ -266,26 +266,26 @@ actionsHelp() todo.txt. If TERM specified, considers only tasks that contain TERM(s). - move ITEM# DEST [SRC] - mv ITEM# DEST [SRC] - Moves a line from source text file (SRC) to destination text file (DEST). + move NR DEST [SRC] + mv NR DEST [SRC] + Moves the line NR from source text file (SRC) to destination text file (DEST). Both source and destination file must be located in the directory defined in the configuration directory. When SRC is not defined it's by default todo.txt. - prepend ITEM# "TEXT TO PREPEND" - prep ITEM# "TEXT TO PREPEND" - Adds TEXT TO PREPEND to the beginning of the task on line ITEM#. + prepend NR "TEXT TO PREPEND" + prep NR "TEXT TO PREPEND" + Adds TEXT TO PREPEND to the beginning of the task on line NR. Quotes optional. - pri ITEM# PRIORITY - p ITEM# PRIORITY - Adds PRIORITY to task on line ITEM#. If the task is already + pri NR PRIORITY + p NR PRIORITY + Adds PRIORITY to task on line NR. If the task is already prioritized, replaces current priority with new PRIORITY. PRIORITY must be a letter between A and Z. - replace ITEM# "UPDATED TODO" - Replaces task on line ITEM# with UPDATED TODO. + replace NR "UPDATED TODO" + Replaces task on line NR with UPDATED TODO. report Adds the number of open tasks and done tasks to report.txt. @@ -495,6 +495,7 @@ replaceOrPrepend() echo "$item $newtodo" ;; esac + fi } @@ -906,7 +907,7 @@ getPadding() _format() { # Parameters: $1: todo input file; when empty formats stdin - # $2: ITEM# number width; if empty auto-detects from $1 / $TODO_FILE. + # $2: NR number width; if empty auto-detects from $1 / $TODO_FILE. # Precondition: None # Postcondition: $NUMTASKS and $TOTALTASKS contain statistics (unless $TODOTXT_VERBOSE=0). @@ -1116,9 +1117,10 @@ case $action in ;; "addto" ) - [ -z "$2" ] && die "usage: $TODO_SH addto DEST \"TODO ITEM\"" + errmsg="usage: $TODO_SH addto DEST \"TODO ITEM\"" + [ -z "$2" ] && die "$errmsg" dest="$TODO_DIR/$2" - [ -z "$3" ] && die "usage: $TODO_SH addto DEST \"TODO ITEM\"" + [ -z "$3" ] && die "$errmsg" shift shift input=$* @@ -1131,7 +1133,7 @@ case $action in ;; "append" | "app" ) - errmsg="usage: $TODO_SH append ITEM# \"TEXT TO APPEND\"" + errmsg="usage: $TODO_SH append NR \"TEXT TO APPEND\"" shift; item=$1; shift getTodo "$item" @@ -1169,7 +1171,7 @@ case $action in "del" | "rm" ) # replace deleted line with a blank line when TODOTXT_PRESERVE_LINE_NUMBERS is 1 - errmsg="usage: $TODO_SH del ITEM# [TERM]" + errmsg="usage: $TODO_SH del NR [TERM]" item=$2 getTodo "$item" @@ -1211,7 +1213,7 @@ case $action in ;; "depri" | "dp" ) - errmsg="usage: $TODO_SH depri ITEM#[, ITEM#, ITEM#, ...]" + errmsg="usage: $TODO_SH depri NR [NR ...]" shift; [ $# -eq 0 ] && die "$errmsg" @@ -1237,7 +1239,7 @@ case $action in ;; "do" | "done" ) - errmsg="usage: $TODO_SH do ITEM#[, ITEM#, ITEM#, ...]" + errmsg="usage: $TODO_SH do NR [NR ...]" # shift so we get arguments to the do request shift; [ "$#" -eq 0 ] && die "$errmsg" @@ -1357,7 +1359,7 @@ case $action in "move" | "mv" ) # replace moved line with a blank line when TODOTXT_PRESERVE_LINE_NUMBERS is 1 - errmsg="usage: $TODO_SH mv ITEM# DEST [SRC]" + errmsg="usage: $TODO_SH mv NR DEST [SRC]" item=$2 dest="$TODO_DIR/$3" src="$TODO_DIR/$4" @@ -1391,7 +1393,7 @@ case $action in ;; "prepend" | "prep" ) - errmsg="usage: $TODO_SH prepend ITEM# \"TEXT TO PREPEND\"" + errmsg="usage: $TODO_SH prepend NR \"TEXT TO PREPEND\"" replaceOrPrepend 'prepend' "$@" ;; @@ -1402,7 +1404,7 @@ case $action in item=$1 newpri=$( printf "%s\n" "$2" | tr '[:lower:]' '[:upper:]' ) - errmsg="usage: $TODO_SH pri ITEM# PRIORITY[, ITEM# PRIORITY, ...] + errmsg="usage: $TODO_SH pri NR PRIORITY [NR PRIORITY ...] note: PRIORITY must be anywhere from A to Z." [ "$#" -lt 2 ] && die "$errmsg" @@ -1438,7 +1440,7 @@ note: PRIORITY must be anywhere from A to Z." ;; "replace" ) - errmsg="usage: $TODO_SH replace ITEM# \"UPDATED ITEM\"" + errmsg="usage: $TODO_SH replace NR \"UPDATED ITEM\"" replaceOrPrepend 'replace' "$@" ;; diff --git a/todo_completion b/todo_completion index 6f67c2fa..3287efea 100755 --- a/todo_completion +++ b/todo_completion @@ -25,7 +25,7 @@ _todo() elif [[ $COMP_CWORD -gt 2 && ( \ "${COMP_WORDS[COMP_CWORD-2]}" =~ ^($MOVE_COMMAND_PATTERN${_todo_file2_actions:+|${_todo_file2_actions}})$ || \ "${COMP_WORDS[COMP_CWORD-3]}" =~ ^($MOVE_COMMAND_PATTERN${_todo_file3_actions:+|${_todo_file3_actions}})$ ) ]]; then - # "move ITEM# DEST [SRC]" has file arguments on positions 2 and 3. + # "move NR DEST [SRC]" has file arguments on positions 2 and 3. completions=$(eval TODOTXT_VERBOSE=0 $_todo_sh command listfile 2>/dev/null) else case "$prev" in