This is an example of a simple command line interface (CLI), written in Javascript, which persists data using a JSON file.
Run npm install
then npm run demo
to try the demo CLI.
app.js
loads up an API library which is used to read and write a JSON file.
In the demo, the API has only 1 resource: "books".
The CLI is displayed to the user using lots of console.log
s.
It uses a library called readline-sync
to request user input.
Here are some examples to get you thinking:
- Reddit-style posts with comments, upvotes and downvotes
- Movie listings with times, tickets, even seating allocations
- Recipe organisr, users can create recipes and add tags, search through tagged recipes
Feel free to make one of these suggestions or come up with something else.
Create a fork of this repo and clone it down to your machine.
Open lib/db.json
and update the file to use an appropriate data structure for your app.
Some possible data structures for the above suggested topics can be found here.
Open app.js
and start building your CLI!
Go here to read about how to use the API.
- All 4 CRUD actions for 1 resource (e.g.
books
orposts
) - Main Menu which lists avaiable options
- Return to main menu after completing actions
- Handling unknown options