Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
drop support for using an array in the help option
Just use a template literal instead.
  • Loading branch information
sindresorhus committed Jul 10, 2016
1 parent 578733e commit c80321d
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
4 changes: 0 additions & 4 deletions index.js
Expand Up @@ -41,10 +41,6 @@ module.exports = (opts, minimistOpts) => {
minimistOpts.string.splice(index, 1);
}

if (Array.isArray(opts.help)) {
opts.help = opts.help.join('\n');
}

const pkg = typeof opts.pkg === 'string' ? require(path.join(parentDir, opts.pkg)) : opts.pkg;
const argv = minimist(opts.argv, minimistOpts);
let help = redent(trimNewlines((opts.help || '').replace(/\t+\n*$/, '')), 2);
Expand Down
3 changes: 0 additions & 3 deletions readme.md
Expand Up @@ -96,9 +96,6 @@ The help text you want shown.

The input is reindented and starting/ending newlines are trimmed which means you can use a [template literal](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/template_strings) without having to care about using the correct amount of indent.

<del>If it's an array each item will be a line.</del><br>
*(Still supported, but you should use a template literal instead.)*

The description will be shown above your help text automatically.

Set it to `false` to disable it altogether.
Expand Down
13 changes: 8 additions & 5 deletions test.js
Expand Up @@ -9,10 +9,10 @@ global.Promise = Promise;
test('return object', t => {
const cli = m({
argv: ['foo', '--foo-bar', '-u', 'cat', '--', 'unicorn', 'cake'],
help: [
'Usage',
' foo <input>'
]
help: `
Usage
foo <input>
`
}, {
'alias': {u: 'unicorn'},
'default': {meow: 'dog'},
Expand All @@ -29,7 +29,10 @@ test('return object', t => {
});

test('support help shortcut', t => {
const cli = m(['unicorn', 'cat']);
const cli = m(`
unicorn
cat
`);
t.is(cli.help, indentString('\nCLI app helper\n\nunicorn\ncat\n', 2));
});

Expand Down

0 comments on commit c80321d

Please sign in to comment.