From fd42f7254bd1334edecc9f1a766e8474cd873817 Mon Sep 17 00:00:00 2001 From: chrysle Date: Fri, 20 Jan 2023 14:03:54 +0100 Subject: [PATCH 1/3] Improved usage messages for actions --- tests/t1100-replace.sh | 2 +- tests/t1200-pri.sh | 2 +- tests/t1400-prepend.sh | 2 +- tests/t1500-do.sh | 6 +-- tests/t1600-append.sh | 2 +- tests/t1700-depri.sh | 2 +- tests/t1800-del.sh | 2 +- tests/t2110-help-action.sh | 16 +++--- tests/t9999-testsuite_example.sh | 2 +- todo.sh | 86 ++++++++++++++++---------------- 10 files changed, 62 insertions(+), 60 deletions(-) diff --git a/tests/t1100-replace.sh b/tests/t1100-replace.sh index bfec5e68..96aa42b2 100755 --- a/tests/t1100-replace.sh +++ b/tests/t1100-replace.sh @@ -14,7 +14,7 @@ todo.sh add notice the daisies > /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 44d8f0e3..9ea1a529 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 79994980..e650e47f 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 af25896c..e53b6c1c 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 6d96e89c..c66f061f 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 06d910c8..23530dcc 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/t9999-testsuite_example.sh b/tests/t9999-testsuite_example.sh index ef25884e..5cfaa8a4 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 fb8d4bce..3c05371d 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. @@ -485,6 +485,7 @@ replaceOrPrepend() echo "$item $newtodo" ;; esac + fi } @@ -899,7 +900,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). @@ -1098,9 +1099,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=$* @@ -1113,7 +1115,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" @@ -1152,7 +1154,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" @@ -1194,7 +1196,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" @@ -1217,7 +1219,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" @@ -1334,7 +1336,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" @@ -1368,7 +1370,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' "$@" ;; @@ -1378,7 +1380,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" @@ -1412,7 +1414,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' "$@" ;; From caf0beba692b81ae98085ad25d7e65896b73b0ef Mon Sep 17 00:00:00 2001 From: chrysle Date: Sun, 5 Mar 2023 14:22:02 +0100 Subject: [PATCH 2/3] Corrected usage messages in USAGE.md --- USAGE.md | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/USAGE.md b/USAGE.md index 4500377b..65fbd1ef 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. ```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` From 902e8b13bb9c7bc2bc792b908fa032d2bd06673a Mon Sep 17 00:00:00 2001 From: Ingo Karkat Date: Thu, 26 Dec 2024 12:01:32 +0100 Subject: [PATCH 3/3] FIX: Replace remaining instances of ITEM# with NR --- USAGE.md | 2 +- tests/actions-test-lib.sh | 4 ++-- tests/t6040-completion-files.sh | 6 +++--- tests/t6060-completion-addon-files.sh | 12 ++++++------ tests/t8020-actions-help.sh | 16 ++++++++-------- todo_completion | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/USAGE.md b/USAGE.md index 65fbd1ef..b6b4f0f7 100644 --- a/USAGE.md +++ b/USAGE.md @@ -87,7 +87,7 @@ 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 NR [NR ...] diff --git a/tests/actions-test-lib.sh b/tests/actions-test-lib.sh index 51d4eefc..0bbe91ad 100644 --- a/tests/actions-test-lib.sh +++ b/tests/actions-test-lib.sh @@ -7,7 +7,7 @@ make_action() cat > ".todo.actions.d/$1" < ".todo.actions.d/$1/$1" <>> 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/todo_completion b/todo_completion index b285a63d..4de441da 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