A command-line (CLI) program that lets you manage your todos.
-
The app can be run in the console with
./todo
. -
The app should read from and write to a
todo.txt
text file. Each todo item occupies a single line in this file. Here is an example file that has 2 todo items.
water the plants
change light bulb
-
When a todo item is completed, it should be removed from
todo.txt
and instead added to thedone.txt
text file. This file has a different format:x 2020-06-12 the text contents of the todo item
- the letter x
- the current date in
yyyy-mm-dd
format - the original text
The date when the todo is marked as completed is recorded in the
yyyy-mm-dd
format (ISO 8601). For example, a date like15th August, 2020
is represented as2020-08-15
. -
The application must open the files
todo.txt
anddone.txt
from where the app is run, and not where the app is located. For example, if we invoke the app like this:$ cd /path/to/plans $ /path/to/apps/todo ls
The application should look for the text files in
/path/to/plans
, since that is the user’s current directory.
Executing the command without any arguments, or with a single argument help
prints the CLI usage.
$ ./todo.sh help
Usage :-
$ ./todo.sh add "todo item" # Add a new todo
$ ./todo.sh ls # Show remaining todos
$ ./todo.sh del NUMBER # Delete a todo
$ ./todo.sh done NUMBER # Complete a todo
$ ./todo.sh help # Show usage
$ ./todo.sh report # Statistics
Use the ls
command to see all the todos that are not yet complete. The most recently added todo should be displayed first.
$ ./todo.sh ls
[2] change light bulb
[1] water the plants
Use the add
command. The text of the todo item should be enclosed within double quotes (otherwise only the first word is considered as the todo text, and the remaining words are treated as different arguments).
$ ./todo.sh add "the thing i need to do"
Added todo: "the thing i need to do"
Use the del
command to remove a todo item by its number.
$ ./todo.sh del 3
Deleted todo #3
Attempting to delete a non-existent todo item should display an error message.
$ ./todo.sh del 5
Error: todo #5 does not exist. Nothing deleted.
Use the done
command to mark a todo item as completed by its number.
$ ./todo.sh done 1
Marked todo #1 as done.
Attempting to mark a non-existed todo item as completed will display an error message.
$ ./todo.sh done 5
Error: todo #5 does not exist.
Use the report
command to see the latest tally of pending and completed todos.
$ ./todo.sh report
yyyy-mm-dd Pending : 1 Completed : 4