Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated add command to accept lowercase priority #230

Merged
merged 3 commits into from
Oct 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions tests/t1010-add-date.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,22 @@ TODO: 2 of 2 tasks shown
TODO: 2 deleted.
EOF

test_todo_session 'cmd line first day with lowercase priority' <<EOF
>>> todo.sh -pt add '(b) notice the daisies'
2 (B) 2009-02-13 notice the daisies
TODO: 2 added.

>>> todo.sh -p list
2 (B) 2009-02-13 notice the daisies
1 2009-02-13 notice the daisies
--
TODO: 2 of 2 tasks shown

>>> todo.sh -npf del 2
2 (B) 2009-02-13 notice the daisies
TODO: 2 deleted.
EOF

test_tick

test_todo_session 'cmd line second day' <<EOF
Expand Down
14 changes: 14 additions & 0 deletions todo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,19 @@ replaceOrPrepend()
fi
}

uppercasePriority()
{
# Precondition: $input contains task text for which to uppercase priority.
# Postcondition: Modifies $input.
lower=( {a..z} )
upper=( {A..Z} )
for ((i=0; i<26; i++))
do
upperPriority="${upperPriority};s/^[(]${lower[i]}[)]/(${upper[i]})/"
done
input=$(echo "$input" | sed $upperPriority)
}

#Preserving environment variables so they don't get clobbered by the config file
OVR_TODOTXT_AUTO_ARCHIVE="$TODOTXT_AUTO_ARCHIVE"
OVR_TODOTXT_FORCE="$TODOTXT_FORCE"
Expand Down Expand Up @@ -773,6 +786,7 @@ _addto() {
file="$1"
input="$2"
cleaninput
uppercasePriority

if [[ $TODOTXT_DATE_ON_ADD = 1 ]]; then
now=$(date '+%Y-%m-%d')
Expand Down