You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 22, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 22, 2023. It is now read-only.
Is it possible to hydrate a list of options in the flags from an async function? A good use case would be to dynamically detect the input options for an array.
I'm also looking for more flexibility in this area.
Specifically I want installed plugins (using @oclif/plugin-plugins) to be able to register themselves using hooks (runHook). runHooks is async and also not possible to execute this.config.runHooks outside of the Command's instance context, as far as I can tell.
Are there any way to currently do this?
import{Command,flags}from'@oclif/command'import{compilerRegistry}from'../compiler-registry';exportdefaultclassExtractextendsCommand{staticflags={compiler: flags.string({char: 'c',required: true,description: 'Compiler to use for translations',options: ()=>{returncompilerRegistry.getRegistered().map(compiler=>compiler.shortName);}})}asyncinit(){awaitthis.config.runHook('register-compilers',{id: 'register-compilers',registry: compilerRegistry});}}
Activity
RasPhilCo commentedon Nov 12, 2019
Options is
string[]type. Would need some reworking to accomplish. You could get "close" and enforce options with a custom flag parser.biesbjerg commentedon Mar 28, 2020
I'm also looking for more flexibility in this area.
Specifically I want installed plugins (using
@oclif/plugin-plugins) to be able to register themselves using hooks (runHook).runHooksisasyncand also not possible to executethis.config.runHooksoutside of theCommand's instance context, as far as I can tell.Are there any way to currently do this?
sisou commentedon Aug 25, 2021
In my case I would like to make a flag's
defaultfunction async, e.g. return aPromise. Is that reasonable?