Skip to content

Commit

Permalink
Add feature to check/uncheck multiple tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
coderick14 committed May 2, 2018
1 parent be790e5 commit cec1555
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
22 changes: 7 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Built with love](http://forthebadge.com/images/badges/built-with-love.svg)
# Tusker
A dead simple todo manager in *less than 100 lines* of code.
A dead simple todo manager in about *a hundred lines* of code.
For those who live in the terminal.

### Installation
Expand All @@ -19,31 +19,23 @@ tusker show
2 ❌ Collect NOC certificate 25 April 2018 11:53:23
3 ❌ Fill rems 25 April 2018 11:53:25
```
- Mark a task as done
- Mark one or more tasks as done
```
tusker check 1
tusker check 1 3
tusker show
1 ✓ Collect laundry 25 April 2018 11:53:21
2 ❌ Collect NOC certificate 25 April 2018 11:53:23
3 Fill rems 25 April 2018 11:53:25
3 Fill rems 25 April 2018 11:53:25
```
- Mark a task as undone
- Mark one or more tasks as undone
```
tusker uncheck 1
tusker uncheck 1 3
tusker show
1 ❌ Collect laundry 25 April 2018 11:53:21
2 ❌ Collect NOC certificate 25 April 2018 11:53:23
3 ❌ Fill rems 25 April 2018 11:53:25
```
- Delete a task from the list
```
tusker del 2
tusker show
1 ❌ Collect laundry 25 April 2018 11:53:21
2 ❌ Fill rems 25 April 2018 11:53:25
```

- Delete multiple tasks from the list
- Delete one or more tasks from the list
```
tusker del 1 3
tusker show
Expand Down
28 changes: 16 additions & 12 deletions tusker
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,9 @@ check_args() {
return
fi

if [ $# -gt 1 ] && ([ "$1" = "add" ] || [ "$1" = "del" ]); then
if [ $# -gt 1 ]; then
return
fi

if [ $# -ne 2 ]; then
else
printf "Not a valid command. Type 'tusker help' for usage.\n"
exit
fi
Expand Down Expand Up @@ -55,13 +53,17 @@ delete_task() {
}

check_task() {
task_id=$1
sed -i "$task_id s/^./$TICK/" "$FILE_NAME"
for task_id in "$@"
do
sed -i "$task_id s/^./$TICK/" "$FILE_NAME"
done
}

uncheck_task() {
task_id=$1
sed -i "$task_id s/^./$CROSS/" "$FILE_NAME"
for task_id in "$@"
do
sed -i "$task_id s/^./$CROSS/" "$FILE_NAME"
done
}

show_tasks() {
Expand Down Expand Up @@ -96,13 +98,15 @@ main() {
;;

check)
check_task "$2"
printf "Task marked as done\n"
shift
check_task "$@"
printf "Task(s) marked as done\n"
;;

uncheck)
uncheck_task "$2"
printf "Task marked as undone\n"
shift
uncheck_task "$@"
printf "Task(s) marked as undone\n"
;;

show)
Expand Down

0 comments on commit cec1555

Please sign in to comment.