Allow custom description for special options#1882
Conversation
|
@OsmanAltun being able to set a custom description and aliases was already supported for The fact that the approach of setting a description and alias through |
I already know this and did this on day one, however if help and version could somehow be treated the same as a non-special options, I could place all options in a single place. This is better for readability I believe. Expected: // variables
const options = {
streaming: {
chromecast: { desc: 'Google Chromecast', defaultDescription: 'all' },
},
simple: {
t: { alias: 'subtitles', desc: 'Load subtitles file', type: 'string', requiresArg: true },
h: { alias: 'help', desc: 'help info' },
v: { alias: 'version', desc: 'version info' }
},
advanced: {
p: { alias: 'port', desc: 'Change the http server port', default: 8000, requiresArg: true },
}
}
// config
yargs
.command(commands)
.options(options.streaming).group(Object.keys(options.streaming), 'Options (streaming): ')
.options(options.simple).group(Object.keys(options.simple), 'Options (simple): ')
.options(options.advanced).group(Object.keys(options.advanced), 'Options (advanced)')currently: // variables
const options = {
streaming: {
chromecast: { desc: 'Google Chromecast', defaultDescription: 'all' },
},
simple: {
t: { alias: 'subtitles', desc: 'Load subtitles file', type: 'string', requiresArg: true },
},
advanced: {
p: { alias: 'port', desc: 'Change the http server port', default: 8000, requiresArg: true },
}
}
// config
yargs
.command(commands)
.options(options.streaming).group(Object.keys(options.streaming), 'Options (streaming): ')
.options(options.simple).group(Object.keys(options.simple).concat(['help', 'version']), 'Options (simple): ')
.options(options.advanced).group(Object.keys(options.advanced), 'Options (advanced)')
.alias({ h: 'help', v: 'version' })
.describe({ help: 'Show help information', version: 'Show version information' })Having said that, this is no big deal since I got the intended behavior already, but I would appreciate it if u opened an issue referencing this to fix at a later date/release maybe. |
This PR fixes #1820