fluvio icon indicating copy to clipboard operation
fluvio copied to clipboard

[Bug]: `fluvio completion zsh` prints a script instead of installing command completion

Open ajhunyady opened this issue 2 years ago • 3 comments

 % fluvio completions zsh
#compdef fluvio

autoload -U is-at-least

_fluvio() {
    typeset -A opt_args
    typeset -a _arguments_options
    local ret=1

    if is-at-least 5.2; then
        _arguments_options=(-s -S -C)
    else
        _arguments_options=(-s -C)
    fi

    local context curcontext="$curcontext" state line
    _arguments "${_arguments_options[@]}" \
'-h[Print help information]' \
'--help[Print help information]' \
":: :_fluvio_commands" \
"*::: :->fluvio" \
....

ajhunyady avatar Aug 12 '22 14:08 ajhunyady

Although it is poorly documented for the less experienced, this is not a bug, this is a convention. The "proper" way to fix this would be through package management or modifying the user's startup script. (Neither of which we support at the moment)

Adding shell completions are a series of scripts that are loaded when you start your shell up.

https://stackoverflow.com/questions/67695861/how-should-i-install-a-zsh-completion-function-so-that-it-works-for-all-users-r


We have some hint for loading in the CLI doc, but only for bash.

$ fluvio completions --help
fluvio-latest-completions
Generate command-line completions for Fluvio

Run the following two commands to enable fluvio command completions.

Open a new terminal for the changes to take effect.

$ fluvio completions bash > ~/fluvio_completions.sh {n}$ echo "source ~/fluvio_completions.sh" >>
~/.bashrc

USAGE:
    fluvio-latest completions <SUBCOMMAND>

OPTIONS:
    -h, --help
            Print help information

SUBCOMMANDS:
    bash
            Generate CLI completions for bash
    zsh
            Generate CLI completions for zsh
    fish
            Generate CLI completions for fish
    help
            Print this message or the help of the given subcommand(s)

tjtelan avatar Aug 12 '22 15:08 tjtelan

I suppose a fix could be to offer a similar hint for zsh, and fish. As of right now, on my Macbook running zsh only displays available commands:

% fluvio completions -h
fluvio-stable-completions 
Generate command-line completions for Fluvio

USAGE:
    fluvio-stable completions <SUBCOMMAND>

OPTIONS:
    -h, --help    Print help information

SUBCOMMANDS:
    bash    Generate CLI completions for bash
    zsh     Generate CLI completions for zsh
    fish    Generate CLI completions for fish
    help    Print this message or the help of the given subcommand(s)

ajhunyady avatar Aug 12 '22 16:08 ajhunyady

For fish I belive it looks something like

fluvio completions fish > ~/.config/fish/completions/fluvio.fish

I had to do some googling to figure that out, so it might be helpful to add a hint in the fluvio completions -h message.

mfdorst avatar Aug 18 '22 07:08 mfdorst

Stale issue message

github-actions[bot] avatar Oct 17 '22 11:10 github-actions[bot]