Last active
June 10, 2020 18:30
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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