Skip to content

Instantly share code, notes, and snippets.

@samyranavela
Last active March 1, 2018 21:51
Show Gist options
  • Save samyranavela/2d3880ab9acdaa884d07da2ec280c9ef to your computer and use it in GitHub Desktop.
Save samyranavela/2d3880ab9acdaa884d07da2ec280c9ef to your computer and use it in GitHub Desktop.
{
"presets": ["env"]
}
#!/usr/bin/env node
'use strict';
require("babel-register");
require('../src/index.js');
{
"name": "hello",
"version": "1.0.0",
"description": "",
"main": "src/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"bin": {
"hello": "bin/hello.js"
},
"dependencies": {
"chalk": "^2.3.1",
"commander": "^2.14.1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-register": "^6.26.0"
}
}
import program from 'commander';
import chalk from 'chalk';
const types = (args) => {
return args.split(',');
}
program
.version('0.1.0')
.arguments('<name>')
.option('-t, --type <type>', 'Types', types, [])
.action((name, options) => {
console.log(chalk.blue('Hello %s'), name);
if (options.type.length)
console.log(options.type);
})
.parse(process.argv);
if (!program.args.length) program.help();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment