0

I have a CLI application that uses Oclif and NodeJS. I have an autocomplete script that looks like this:

# func gets called for the exec binart when Tab is pressed
# eg exec [Tab] [Tab] calls __func()

__func()
{
    Perform an http request that takes 2-3 seconds
    Populate COMPREPLY with autocomplete values
}

complete -o nospace -F __func exec

Since pressing Tab takes a few seconds, it would be nice to have a spinner like functionality in the shell, so that the user can see that the autocomplete is running.

How can I achieve this? Instead of a spinner a progress bar would be nice, or some dots that would indicate loading (...).

anegru
  • 1,023
  • 2
  • 13
  • 29

1 Answers1

1

Have you tried to call a spinner before and after your command?

Example spinner:

Example with your code:

    __func()
    {
        spinner.start()
        Perform an http request that takes 2-3 seconds
        Populate COMPREPLY with autocomplete values
        spinner.end()
    }

    complete -o nospace -F __func exec
f4zr
  • 70
  • 1
  • 7