You've decided you want to count some things, by keeping a tally. But you're not sure yet what you want to count. So you'd like a simple script that takes the name of something, plus an optional count, and adds that count to the tally for that kind of something. Note that your program needs to have persistence, by storing to a simple database on disk.
Here's an example interactive session with a working program:
❯ bun shopping.js
Nothing to shop for yet!
❯ bun shopping.js badger
Adding 1 x "badger"
Here's your current shopping list:
---
1 badger
❯ bun shopping.js badger 4
Adding 4 x "badger"
Here's your current shopping list:
---
5 badger
❯ bun shopping.js "any kind of fruit" 4
Adding 4 x "any kind of fruit"
Here's your current shopping list:
---
5 badger
4 any kind of fruit
❯ bun shopping.js socks
Adding 1 x "socks"
Here's your current shopping list:
---
5 badger
4 any kind of fruit
1 socks
❯ bun shopping.js
Here's your current shopping list:
---
5 badger
4 any kind of fruit
1 socks
❯ bun shopping.js CLEAR
Shopping list cleared!
Nothing to shop for yet! if there are no items currently on the shopping listCLEAR then delete all items from the shpping list and show the message Shopping list cleared!Here's your current shopping list: with a list of all items and their count shown below, as per the interactive session example abovecat [filename]