Last active
August 29, 2015 14:26
-
-
Save yoshuawuyts/ba12001596cc001de52e to your computer and use it in GitHub Desktop.
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 cliclopts = require('cliclopts') | |
const minimist = require('minimist') | |
const fs = require('fs') | |
const quickStub = require('./') | |
const opts = cliclopts([ | |
{ | |
name: 'help', | |
abbr: 'h', | |
boolean: true | |
}, | |
{ | |
name: 'verbose', | |
abbr: 'v', | |
boolean: true | |
} | |
]) | |
const argv = minimist(process.argv.slice(2), opts.options()) | |
// help | |
if (argv.help) usage(0) | |
if (process.argv.length <= 2 && process.stdin.isTTY) usage(1) | |
// version | |
if (argv.v || argv.version) { | |
process.stdout.write(require('../package.json').version) | |
process.exit(0) | |
} | |
// run commands | |
quickStub(argv) | |
// print usage | |
// num? -> null | |
function usage (exitCode) { | |
exitCode = exitCode || 0 | |
fs.createReadStream(__dirname + '/usage.txt') | |
.pipe(process.stdout) | |
.on('close', process.exit.bind(null, exitCode)) | |
} |
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
quick-base - generate a fresh module | |
Usage: quick-base <name> | |
Options: | |
-h, --help Output usage information | |
-v, --version Output version number | |
Examples: | |
$ quick-base hello-world # generate 'hello-world' module | |
Docs: https://github.com/yoshuawuyts/quick-stub | |
Bugs: https://github.com/yoshuawuyts/quick-stub/issues |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
newer version, removed race conditions