Exercises
Powerful Command-Line Applications in Go — by Ricardo Gerardi (27 / 127)
Published in
1 min readMar 23, 2022
👈 Capturing Input from STDIN | TOC | Wrapping Up 👉
You can try the following exercises to expand your skills:
- Implement the flag -del to delete an item from the list. Use the Delete method from the API to perform the action.
- Add another flag to enable verbose output, showing information like date/time.
- Add another flag to prevent displaying completed items.
- Update the custom usage function to include additional instructions on how to provide new tasks to the tool.
- Include test cases for the remaining options, such as -complete.
- Update the tests to use the TODO_FILENAME environment variable instead of hard-coding the test file name so that it doesn’t cause conflicts with an existing file.
- Update the getTask function allowing it to handle multiline input from STDIN. Each line should be a new task in the list.
👈 Capturing Input from STDIN | TOC | Wrapping Up 👉
Powerful Command-Line Applications in Go by Ricardo Gerardi can be purchased in other book formats directly from the Pragmatic Programmers. If you notice a code error or formatting mistake, please let us know here so that we can fix it.