CLI Commands
Termivore has a built in way to create a CLI with functioning commands, plus some built in features such as a help command and a -v version flag.
If you're looking to setup a new CLI, it's recommended you use the termivore CLI to spin up your project, if you wish to do it manually you can follow this section.
Create the CLI
Set up your command
To actually use your CLI, you will need to setup a few things first, please see our page on Node.js/NPM CLI Information
Once your package.json file is setup correctly and you have made your entry file executable you can use Termivore's CLI
class to create your CLI.
You can do this like so:
The above will create and start a CLI (with no commands, yet...) which will have a help command and a -v option for checking version. See the next section for adding commands to your CLI.
Ensure that you don't attempt to add commands or alter myCli
(or whatever your CLI variable is named) after you call the start()
command as those additions won't be reflected in the CLI.