Demo cli app implemented using npm commander, progress and ora (spinner)
demo cli app
Clone this repository
git clone https://github.com/carballosa/cli-demo.git
cd commander-test
Install app dependencies
npm install
Build the app to the dist
folder
npm run build
Deploy app’s entry point to the bin
folder
npm run deploy
Install app as a global cli
package
| WARNING: You need to perform this step from a console or terminal that is running as the user for which you want to install this command. For example, if you run it from VSCode integrated console, which normally runs as admin, then this command will only be available in consoles running as admin. |
| —- |
npm install -g
See app usage
> pizza -h
Usage: pizza [options]
Order a pizza with your preferred toppings
Options:
-v, --version output the version number
-p, --peppers Add peppers
-P, --pineapple Add pineapple
-b, --bbq-sauce Add bbq sauce
-c, --cheese [name] Add the specified type of cheese
-$, --card <name> Indicate the payment card (default: visa)
-h, --help output usage information
Check installed version
> pizza -v
0.1.0
Run without arguments
> pizza
you ordered a standard pizza
you will pay with visa
Run with a non-default argument (not visa)
> pizza -$ mastercard
you ordered a standard pizza
you will pay with mastercard
Run combining serveral flag arguments (multiple toppings)
> pizza -pbc
you ordered a pizza with:
- peppers
- bbq
- standard cheese
you will pay with visa
Run with a non-flag argument (not standard cheese)
> pizza -c mozzarella
you ordered a pizza with:
- mozzarella cheese
you will pay with visa