Skip to content
Permalink
Browse files

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 c80321d2ec6733d502335edb29d173f12bbf1111
Showing with 8 additions and 12 deletions.
  1. +0 −4 index.js
  2. +0 −3 readme.md
  3. +8 −5 test.js
@@ -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);
@@ -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.
13 test.js
@@ -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'},
@@ -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));
});

0 comments on commit c80321d

Please sign in to comment.
You can’t perform that action at this time.