Summary: This is a review submission for a CLI tool built as part of a code exercise, to consume the first 'n' even or odd numbered TODOs from a pre-determined resource URL and output the title and whether it is completed or not.
- This CLI tool has been built as a
Node.js
CLI application. - The command supports two options to configure both the number of TODOs that get consumed and whether to read
even
orodd
numbered TODOs. - 100% code coverage!! Yes, really!
- A simple
Dockerfile
is included so the tool can be run in a container.
You can run the unit tests using the following commands (note that you'll need to have Node.js >= v20 installed on your local machine):
npm install
npm test
# run this command to get code coverage
npm run coverage
This is the recommended way to quickly get up and running so you can test out the tool. First make sure you have Docker and git installed on your host machine. Then do the following:
-
Clone the repository to your local environment.
-
Navigate to the project's root directory, then build the image:
cd path/to/project docker build -t cli-todos-container .
-
Run the CLI tool in your container:
docker run cli-todos-container
-
You can pass options to configure the number of TODOs to consume and whether to consume even or odd numbered TODOs, like so:
docker run cli-todos-container --count 5 --selection odd
You can pass any supported options for the CLI tool as arguments to the container and they will be passed along to the tool. Example:
docker run cli-todos-container --help
Usage: todos-consumer [options]
Consume the first 'n' even or odd numbered TODOs from a pre-determined resource
URL and output the title and whether it is completed or not.
Options:
-V, --version output the version number
-c, --count <count> The number of TODOs to consume. Must be >= 1.
(default: 20)
-s, --selection <even | odd> The selection of TODOs to consume, if even or
odd numbered. (default: "even")
-h, --help display help for command