Skip to content

Instantly share code, notes, and snippets.

@smks
Last active June 10, 2020 18:30
Show Gist options
  • Save smks/5df989952900fd4fe9ee4b3fb8bcae1f to your computer and use it in GitHub Desktop.
Save smks/5df989952900fd4fe9ee4b3fb8bcae1f to your computer and use it in GitHub Desktop.
This is a sample commander CLI application used in Medium Article - How I automated my Job with Node JS
#! /usr/bin/env node
const mason = require('commander');
const { version } = require('./package.json');
const console = require('console');
// commands
const create = require('./commands/create');
const setup = require('./commands/setup');
mason
.version(version);
mason
.command('setup [env]')
.description('run setup commands for all envs')
.action(setup);
mason
.command('create <ticketId>')
.description('creates a new game')
.action(create);
mason
.command('*')
.action(() => {
mason.help();
});
mason.parse(process.argv);
if (!mason.args.length) {
mason.help();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment