Skip to content

Commit cec1555

Browse files
committed
Add feature to check/uncheck multiple tasks
1 parent be790e5 commit cec1555

File tree

2 files changed

+23
-27
lines changed

2 files changed

+23
-27
lines changed

README.md

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
![Built with love](http://forthebadge.com/images/badges/built-with-love.svg)
22
# Tusker
3-
A dead simple todo manager in *less than 100 lines* of code.
3+
A dead simple todo manager in about *a hundred lines* of code.
44
For those who live in the terminal.
55

66
### Installation
@@ -19,31 +19,23 @@ tusker show
1919
2 ❌ Collect NOC certificate 25 April 2018 11:53:23
2020
3 ❌ Fill rems 25 April 2018 11:53:25
2121
```
22-
- Mark a task as done
22+
- Mark one or more tasks as done
2323
```
24-
tusker check 1
24+
tusker check 1 3
2525
tusker show
2626
1 ✓ Collect laundry 25 April 2018 11:53:21
2727
2 ❌ Collect NOC certificate 25 April 2018 11:53:23
28-
3 Fill rems 25 April 2018 11:53:25
28+
3 Fill rems 25 April 2018 11:53:25
2929
```
30-
- Mark a task as undone
30+
- Mark one or more tasks as undone
3131
```
32-
tusker uncheck 1
32+
tusker uncheck 1 3
3333
tusker show
3434
1 ❌ Collect laundry 25 April 2018 11:53:21
3535
2 ❌ Collect NOC certificate 25 April 2018 11:53:23
3636
3 ❌ Fill rems 25 April 2018 11:53:25
3737
```
38-
- Delete a task from the list
39-
```
40-
tusker del 2
41-
tusker show
42-
1 ❌ Collect laundry 25 April 2018 11:53:21
43-
2 ❌ Fill rems 25 April 2018 11:53:25
44-
```
45-
46-
- Delete multiple tasks from the list
38+
- Delete one or more tasks from the list
4739
```
4840
tusker del 1 3
4941
tusker show

tusker

+16-12
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ check_args() {
2020
return
2121
fi
2222

23-
if [ $# -gt 1 ] && ([ "$1" = "add" ] || [ "$1" = "del" ]); then
23+
if [ $# -gt 1 ]; then
2424
return
25-
fi
26-
27-
if [ $# -ne 2 ]; then
25+
else
2826
printf "Not a valid command. Type 'tusker help' for usage.\n"
2927
exit
3028
fi
@@ -55,13 +53,17 @@ delete_task() {
5553
}
5654

5755
check_task() {
58-
task_id=$1
59-
sed -i "$task_id s/^./$TICK/" "$FILE_NAME"
56+
for task_id in "$@"
57+
do
58+
sed -i "$task_id s/^./$TICK/" "$FILE_NAME"
59+
done
6060
}
6161

6262
uncheck_task() {
63-
task_id=$1
64-
sed -i "$task_id s/^./$CROSS/" "$FILE_NAME"
63+
for task_id in "$@"
64+
do
65+
sed -i "$task_id s/^./$CROSS/" "$FILE_NAME"
66+
done
6567
}
6668

6769
show_tasks() {
@@ -96,13 +98,15 @@ main() {
9698
;;
9799

98100
check)
99-
check_task "$2"
100-
printf "Task marked as done\n"
101+
shift
102+
check_task "$@"
103+
printf "Task(s) marked as done\n"
101104
;;
102105

103106
uncheck)
104-
uncheck_task "$2"
105-
printf "Task marked as undone\n"
107+
shift
108+
uncheck_task "$@"
109+
printf "Task(s) marked as undone\n"
106110
;;
107111

108112
show)

0 commit comments

Comments
 (0)