Skip to content

Commit

Permalink
Fix docs regarding meow arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Nov 5, 2018
1 parent cd635d4 commit 439ac9b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
10 changes: 5 additions & 5 deletions index.js
Expand Up @@ -14,10 +14,10 @@ const normalizePackageData = require('normalize-package-data');
delete require.cache[__filename];
const parentDir = path.dirname(module.parent.filename);

module.exports = (helpMessage, options) => {
if (typeof helpMessage === 'object' && !Array.isArray(helpMessage)) {
options = helpMessage;
helpMessage = '';
module.exports = (helpText, options) => {
if (typeof helpText !== 'string') {
options = helpText;
helpText = '';
}

options = {
Expand All @@ -28,7 +28,7 @@ module.exports = (helpMessage, options) => {
argv: process.argv.slice(2),
inferType: false,
input: 'string',
help: helpMessage,
help: helpText,
autoHelp: true,
autoVersion: true,
booleanDefault: false,
Expand Down
13 changes: 9 additions & 4 deletions readme.md
Expand Up @@ -67,7 +67,8 @@ foo(cli.input[0], cli.flags);

## API

### meow(options, [minimistOptions])
### meow(helpText, [options])
### meow(options)

Returns an `Object` with:

Expand All @@ -78,11 +79,15 @@ Returns an `Object` with:
- `showHelp([code=2])` *(Function)* - Show the help text and exit with `code`
- `showVersion()` *(Function)* - Show the version text and exit

#### options
#### helpText

Type: `string`

Type: `Object` `Array` `string`
Shortcut for the `help` option.

Can either be a string/array that is the `help` or an options object.
#### options

Type: `Object`

##### flags

Expand Down
12 changes: 7 additions & 5 deletions test.js
Expand Up @@ -107,7 +107,7 @@ test('type inference', t => {
});

test('booleanDefault: undefined, filter out unset boolean args', t => {
t.deepEqual(meow('help', {
t.deepEqual(meow({
argv: ['--foo'],
booleanDefault: undefined,
flags: {
Expand All @@ -129,7 +129,7 @@ test('booleanDefault: undefined, filter out unset boolean args', t => {
});

test('boolean args are false by default', t => {
t.deepEqual(meow('help', {
t.deepEqual(meow({
argv: ['--foo'],
flags: {
foo: {
Expand All @@ -151,17 +151,19 @@ test('boolean args are false by default', t => {
});

test('enforces boolean flag type', t => {
const cli = meow('', {
const cli = meow({
argv: ['--cursor=false'],
flags: {
cursor: {type: 'boolean'}
cursor: {
type: 'boolean'
}
}
});
t.deepEqual(cli.flags, {cursor: false});
});

test('accept help and options', t => {
t.deepEqual(meow('help', {
t.deepEqual(meow({
argv: ['-f'],
flags: {
foo: {
Expand Down

0 comments on commit 439ac9b

Please sign in to comment.