Search code examples
node.jstypescriptcommand-line-interfaceoclif

Oclif dynamic autocomplete with http call


Does Oclif support making a call to an API and getting the values returned in order to be used for autocomplete? I have the following use case:

  • Multiple users are stored in a database
  • When the user presses show users <Tab> <Tab>, the CLI should make a call to an API that returns all available users.
  • The CLI should use the values returned from the API.
  • The user can then select a user name, for example show users user0001.

Is this possible in Oclif?


Solution

  • 'It is not possible in Oclif, however the Heroku CLI does this. Check out https://github.com/heroku/cli/tree/master/packages/autocomplete for more information.'

    This is the answer from Oclif team regarding this issue. https://github.com/oclif/oclif/issues/332