Skip to content

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:

#!/usr/bin/env node
import { CLI } from 'termivore';

const myCli = new CLI('rootCommand', { version: '1.0.0' });

// Commands go here

myCli.start()
#!/usr/bin/env node
const termivore = require('termivore');

const myCli = new termivore.CLI('rootCommand', { version: '1.0.0' });

// Commands go here

myCli.start()

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.

Add a Command

Add Arguments to a Command

Add options to a Command