restore the kissu branding
[IRC-YouTube-Bot.git] / node_modules / meow / index.js
blobba8e528bffce3d6ab60c91eb93d2aaaf9d07d648
1 'use strict';
2 var path = require('path');
3 var minimist = require('minimist');
4 var indentString = require('indent-string');
5 var objectAssign = require('object-assign');
6 var camelcaseKeys = require('camelcase-keys');
8 // needed to get the uncached parent
9 delete require.cache[__filename];
10 var parentDir = path.dirname(module.parent.filename);
12 module.exports = function (opts, minimistOpts) {
13 opts = objectAssign({
14 pkg: './package.json',
15 argv: process.argv.slice(2)
16 }, opts);
18 var pkg = require(path.join(parentDir, opts.pkg));
19 var argv = minimist(opts.argv, minimistOpts);
20 var help = '\n' + indentString(pkg.description + (opts.help ? '\n\n' + opts.help : '\n'), ' ');
21 var showHelp = function () {
22 console.log(help);
23 process.exit();
26 if (argv.version) {
27 console.log(pkg.version);
28 process.exit();
31 if (argv.help) {
32 showHelp();
35 var _ = argv._;
36 delete argv._;
38 return {
39 input: _,
40 flags: camelcaseKeys(argv),
41 pkg: pkg,
42 help: help,
43 showHelp: showHelp