nats-io / natscli

The NATS Command Line Interface
Apache License 2.0
467 stars 94 forks source link

Unexpected autocomplete behaviour #502

Open Kaarel opened 2 years ago

Kaarel commented 2 years ago

Added the output of nats --completion-script-bash to my .bashrc

Works awesome! with some caveats :)

sylr commented 2 years ago

With zsh it only autocompletes the first word and then is for the second word it proposes the list of first words:

 ✘ sylvain $ nats stream <tab>
account    backup     bench      consumer   context    errors     events     governor   help       kv         latency    object     publish    reply      request    restore    rtt        schema     server     stream     subscribe
sylr commented 1 year ago

@ripienaar any chance someone could look into that ? it's pretty annoying.

ripienaar commented 1 year ago

Agree, quite annoying, but I havnt had time to investigate sorry, help would be appreciated since it's such a infrequently used feature.

The behavior is somewhere deep in the CLI library, I did see there's some hints I can do to help it out but havnt investigated actualy using them.

philpennock commented 1 year ago

(zsh-specific for @sylr's issue, does not address the bash issue)

The Synadia installer for client tools provides https://get-nats.io/zsh.complete.nats aka https://github.com/ConnectEverything/client-tools/blob/main/zsh.complete.nats

That wrapper manages to invoke the CLI-bundled completion interfaces correctly enough that you don't see the issue. But it's not auto-updated along with the client binary. Still, it works today. There's also a zshrc with some copiously-commented examples of things like setting up tab-completion for NATS_CONTEXT using the completion function.

Download https://get-nats.io/zsh.complete.nats to be called _nats somewhere in your $fpath list and restart zsh to get fresh completion and see if that helps?