New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding 'choices' within the option decorator #327
Comments
Hi Jay, an additional configuration could be dynamic choices. Decorators are used in a static manner, if we want to add the choices dynamically, then we could provide this over a function. export interface OptionMetadata { An alternative of that approach could be a second Decorator. We could use it in the same way as in the Inquirer API: @option({ @OptionChoicesFor({name: option}) |
I really like the |
Option choices are now supported either as a static string array or via the `@OptionChoicesFor()` decorator on a class method. This decorator method approach allows for using a class's injected providers to give the chocies, which means they could come from a database or a config file somewhere if the CLI is set up to handle such a case closes #327
Option choices are now supported either as a static string array or via the `@OptionChoicesFor()` decorator on a class method. This decorator method approach allows for using a class's injected providers to give the chocies, which means they could come from a database or a config file somewhere if the CLI is set up to handle such a case closes #327
Added support in 2.5.0 |
Discussed in #326
Originally posted by BenSawary March 18, 2022
I'd like to define a valid list of a commands option argument. Since commander 7, (tj/commander.js#518) it is possible to create an option with choices. Is it possible to add this functionality also in the nest-commander option decorator?
@option({
flags: '--option [option]',
choices: ['a', 'b', 'c'],
defaultValue: 'a'
})
setOption(option: string) {}
The text was updated successfully, but these errors were encountered: