Do not print help for positional arguments as options

This commit is contained in:
Jerko Steiner 2019-08-14 09:18:45 +07:00
parent c0b245067b
commit 9fc4b064da
2 changed files with 3 additions and 4 deletions

View File

@ -256,7 +256,6 @@ describe('argparse', () => {
`${CMD} [OPTIONS] [VALUE...]`, `${CMD} [OPTIONS] [VALUE...]`,
'', '',
'Options:', 'Options:',
' --value [VALUE...] (required)',
' --other number ', ' --other number ',
' --help boolean ', ' --help boolean ',
].join('\n')) ].join('\n'))
@ -381,8 +380,6 @@ describe('argparse', () => {
'Options:', 'Options:',
'-o, --one string first argument ' + '-o, --one string first argument ' +
'(required, default: choice-1, choices: choice-1,choice-2)', '(required, default: choice-1, choices: choice-1,choice-2)',
' --two number (required)',
' --three number ',
' --help boolean ', ' --help boolean ',
].join('\n')) ].join('\n'))
}) })

View File

@ -193,7 +193,9 @@ export function help(command: string, config: IArgsConfig) {
.join(' '), .join(' '),
].join(' ') ].join(' ')
const argsHelp = 'Options:\n' + keys.map(argument => { const options = keys.filter(k => !config[k].positional)
const argsHelp = 'Options:\n' + options.map(argument => {
const argConfig = config[argument] const argConfig = config[argument]
const {alias, type} = argConfig const {alias, type} = argConfig
const name = alias const name = alias