spf13/cobra

ActiveHelp on bash does not handle command-line prefixes adequately

marckhouzam opened this issue · 0 comments

When using ActiveHelp with bash, if the program name is prefixed with a variable or similar, re-printing the command-line does not reprint the prefix.

For example, using the tanzu CLI v1.1.
Notice below that TOKEN=12345 is not shown when the command-line is reprinted. However, if I move my cursor back, the TOKEN=12345 is present but not visible.

bash-5.1$ source <(tanzu completion bash)

bash-5.1$ TOKEN=12345 tanzu context [tab]
Command help: Configure and manage contexts for the Tanzu CLI

bash-5.1$ tanzu context

Refreshing the screen (^L), will show the missing characters.

Notice that pressing [tab] a second time, if there are completion choices, will print those completion choices, and will reprint the command-line appropriately:

bash-5.1$ TOKEN=12345 tanzu context [tab]
Command help: Configure and manage contexts for the Tanzu CLI

bash-5.1$ tanzu context [tab]
Command help: Configure and manage contexts for the Tanzu CLI

bash-5.1$ tanzu context
create  (Create a Tanzu CLI context)                                   list    (List contexts)
delete  (Delete a context from the config)                             unset   (Unset the active context so that it is not used by default.)
get     (Display a context from the config)                            use     (Set the context to be used by default)
bash-5.1$ TOKEN=12345 tanzu context

The same happens with time tanzu context [tab]