Comparing version 1.0.0 to 2.0.0
20
index.js
@@ -15,3 +15,2 @@ 'use strict'; | ||
pkg: './package.json', | ||
requireInput: true, | ||
argv: process.argv.slice(2) | ||
@@ -22,4 +21,7 @@ }, opts); | ||
var argv = minimist(opts.argv, minimistOpts); | ||
var errHelp = (opts.requireInput && !argv.help && argv._.length === 0); | ||
var helpText = '\n' + indentString(pkg.description + (opts.help ? '\n\n' + opts.help : '\n'), ' '); | ||
var help = '\n' + indentString(pkg.description + (opts.help ? '\n\n' + opts.help : '\n'), ' '); | ||
var showHelp = function () { | ||
console.log(help); | ||
process.exit(); | ||
}; | ||
@@ -31,10 +33,4 @@ if (argv.version) { | ||
if (errHelp) { | ||
console.error(helpText); | ||
process.exit(1); | ||
} | ||
if (argv.help) { | ||
console.log(helpText); | ||
process.exit(); | ||
showHelp(); | ||
} | ||
@@ -48,4 +44,6 @@ | ||
flags: camelcaseKeys(argv), | ||
pkg: pkg | ||
pkg: pkg, | ||
help: help, | ||
showHelp: showHelp | ||
}; | ||
}; |
{ | ||
"name": "meow", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "CLI app helper", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -5,3 +5,3 @@ # meow [![Build Status](https://travis-ci.org/sindresorhus/meow.svg?branch=master)](https://travis-ci.org/sindresorhus/meow) | ||
![](https://cloud.githubusercontent.com/assets/170270/4606307/37c6f73c-5218-11e4-8624-e4008e952859.gif) | ||
![](meow.gif) | ||
@@ -15,3 +15,2 @@ | ||
- Outputs description and supplied help text when `--help` | ||
- Outputs the above when no input is supplied *[(can be disabled)](#requireinput)* | ||
@@ -48,5 +47,3 @@ | ||
flags: {rainbowCake: true}, | ||
pkg: { | ||
name: 'foo-app', | ||
... | ||
... | ||
} | ||
@@ -68,2 +65,4 @@ */ | ||
- `pkg` *(object)* - The `package.json` object | ||
- `help` *(object)* - The help text used with `--help` | ||
- `showHelp()` *(function)* - Show the help text and exit | ||
@@ -85,9 +84,2 @@ #### options | ||
##### requireInput | ||
Type: `boolean` | ||
Default: `true` | ||
Require there to be at least one input argument. | ||
##### argv | ||
@@ -94,0 +86,0 @@ |
3251
38
98