Sometimes you may want to coerce an option but the coercing itself is async. My specific use case was to coerce --config with the output of https://github.com/davidtheclark/cosmiconfig, but this might be handy in other situations.
Supporting this would probably require a lot of work, perhaps the maintainers could weight what would need to be changed. In terms of API, nothing would change, except for the .argv:
const argv = await yargs()
.strict()
.option('config', {
type: 'string',
coerce: () => cosmiconfig('my-app'),
})
.argv;
Though, this would be a breaking change. Perhaps, we could have another prop, say .argvPromise to accomplish the same goal.
This thread is to create a discussion about this feature. Feel free to ditch it if it introduces too much complexity.
❤️ yargs
Sometimes you may want to coerce an option but the coercing itself is async. My specific use case was to coerce
--configwith the output of https://github.com/davidtheclark/cosmiconfig, but this might be handy in other situations.Supporting this would probably require a lot of work, perhaps the maintainers could weight what would need to be changed. In terms of API, nothing would change, except for the
.argv:Though, this would be a breaking change. Perhaps, we could have another prop, say
.argvPromiseto accomplish the same goal.This thread is to create a discussion about this feature. Feel free to ditch it if it introduces too much complexity.
❤️ yargs