wormhole-rs completion not working ?

Matthias Geiger <[email protected]>
Newsgroups gmane.comp.shells.zsh.devel,gmane.comp.shells.zsh.user
Message-ID <[email protected]>
Hi all,
I have an issue with a completion file not working correctly.
I'm the maintainer of wormhole-rs 
[0] in Debian, which 
is written in Rust and uses clap-complete (a rust library) during the 
build to generate the completion files. They work for bash and fish OOTB 
as expected. However, in zsh they don't and I want to know why.
If I type "wormhole-rs" and then hit TAB only filenames get completed. 
However, if I manually source the completion file (located under 
/usr/share/zsh/vendor-completions) and then type the same completion 
works as expected.
My .zshrc: [1]

Attached the generated completion file.
Is there something wrong with the generated file ? I suspect so, but 
would like to get some expertise.

best,

werdahias

Links:

[0]: https://tracker.debian.org/pkg/rust-magic-wormhole-cli
[1]: https://codeberg.org/werdahias/graffe/src/branch/main/.zshrc
_wormhole-rs (text/plain, 15.6 KB)
compdef _wormhole-rs wormhole-rs
 _wormhole-rs() { #compdef wormhole-rs

autoload -U is-at-least

_wormhole-rs() {
    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[@]}" : \
'-v[Enable logging to stdout, for debugging purposes]' \
'--verbose[Enable logging to stdout, for debugging purposes]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_wormhole-rs_commands" \
"*::: :->wormhole-rs" \
&& ret=0
    case $state in
    (wormhole-rs)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:wormhole-rs-command-$line[1]:"
        case $line[1] in
            (send)
_arguments "${_arguments_options[@]}" : \
'*--relay-server=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'*--relay=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'--rendezvous-server=[Use a custom rendezvous server. Both sides need to use the same value in order to find each other]:ws://example.org:_urls' \
'--code=[Enter a code instead of generating one automatically]:CODE:_default' \
'-c+[Length of code (in bytes/words)]:NUMWORDS:_default' \
'--code-length=[Length of code (in bytes/words)]:NUMWORDS:_default' \
'--rename=[Suggest a different name to the receiver to keep the file'\''s actual name secret. Not allowed when sending more than one file]:FILE_NAME:_default' \
'--name=[Suggest a different name to the receiver to keep the file'\''s actual name secret. Not allowed when sending more than one file]:FILE_NAME:_default' \
'--force-direct[Disable the relay server support and force a direct connection]' \
'(--force-direct)--force-relay[Always route traffic over a relay server. This hides your IP address from the peer (but not from the server operators. Use Tor for that)]' \
'-v[Enable logging to stdout, for debugging purposes]' \
'--verbose[Enable logging to stdout, for debugging purposes]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::files:_files' \
&& ret=0
;;
(tx)
_arguments "${_arguments_options[@]}" : \
'*--relay-server=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'*--relay=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'--rendezvous-server=[Use a custom rendezvous server. Both sides need to use the same value in order to find each other]:ws://example.org:_urls' \
'--code=[Enter a code instead of generating one automatically]:CODE:_default' \
'-c+[Length of code (in bytes/words)]:NUMWORDS:_default' \
'--code-length=[Length of code (in bytes/words)]:NUMWORDS:_default' \
'--rename=[Suggest a different name to the receiver to keep the file'\''s actual name secret. Not allowed when sending more than one file]:FILE_NAME:_default' \
'--name=[Suggest a different name to the receiver to keep the file'\''s actual name secret. Not allowed when sending more than one file]:FILE_NAME:_default' \
'--force-direct[Disable the relay server support and force a direct connection]' \
'(--force-direct)--force-relay[Always route traffic over a relay server. This hides your IP address from the peer (but not from the server operators. Use Tor for that)]' \
'-v[Enable logging to stdout, for debugging purposes]' \
'--verbose[Enable logging to stdout, for debugging purposes]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::files:_files' \
&& ret=0
;;
(receive)
_arguments "${_arguments_options[@]}" : \
'*--relay-server=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'*--relay=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'--rendezvous-server=[Use a custom rendezvous server. Both sides need to use the same value in order to find each other]:ws://example.org:_urls' \
'--out-dir=[Store transferred file or folder in the specified directory. Defaults to \$PWD]:PATH:_files -/' \
'--noconfirm[Accept file transfer without asking for confirmation]' \
'--yes[Accept file transfer without asking for confirmation]' \
'--force-direct[Disable the relay server support and force a direct connection]' \
'(--force-direct)--force-relay[Always route traffic over a relay server. This hides your IP address from the peer (but not from the server operators. Use Tor for that)]' \
'-v[Enable logging to stdout, for debugging purposes]' \
'--verbose[Enable logging to stdout, for debugging purposes]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::code -- Provide the code now rather than typing it interactively:_default' \
&& ret=0
;;
(rx)
_arguments "${_arguments_options[@]}" : \
'*--relay-server=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'*--relay=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'--rendezvous-server=[Use a custom rendezvous server. Both sides need to use the same value in order to find each other]:ws://example.org:_urls' \
'--out-dir=[Store transferred file or folder in the specified directory. Defaults to \$PWD]:PATH:_files -/' \
'--noconfirm[Accept file transfer without asking for confirmation]' \
'--yes[Accept file transfer without asking for confirmation]' \
'--force-direct[Disable the relay server support and force a direct connection]' \
'(--force-direct)--force-relay[Always route traffic over a relay server. This hides your IP address from the peer (but not from the server operators. Use Tor for that)]' \
'-v[Enable logging to stdout, for debugging purposes]' \
'--verbose[Enable logging to stdout, for debugging purposes]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::code -- Provide the code now rather than typing it interactively:_default' \
&& ret=0
;;
(send-many)
_arguments "${_arguments_options[@]}" : \
'-n+[Only send the file up to n times, limiting the number of people that may receive it. These are also the number of tries a potential attacker gets at guessing the password]:N:_default' \
'--tries=[Only send the file up to n times, limiting the number of people that may receive it. These are also the number of tries a potential attacker gets at guessing the password]:N:_default' \
'--timeout=[Automatically stop providing the file after a certain amount of time]:MINUTES:_default' \
'*--relay-server=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'*--relay=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'--rendezvous-server=[Use a custom rendezvous server. Both sides need to use the same value in order to find each other]:ws://example.org:_urls' \
'--code=[Enter a code instead of generating one automatically]:CODE:_default' \
'-c+[Length of code (in bytes/words)]:NUMWORDS:_default' \
'--code-length=[Length of code (in bytes/words)]:NUMWORDS:_default' \
'--rename=[Suggest a different name to the receiver to keep the file'\''s actual name secret. Not allowed when sending more than one file]:FILE_NAME:_default' \
'--name=[Suggest a different name to the receiver to keep the file'\''s actual name secret. Not allowed when sending more than one file]:FILE_NAME:_default' \
'--force-direct[Disable the relay server support and force a direct connection]' \
'(--force-direct)--force-relay[Always route traffic over a relay server. This hides your IP address from the peer (but not from the server operators. Use Tor for that)]' \
'-v[Enable logging to stdout, for debugging purposes]' \
'--verbose[Enable logging to stdout, for debugging purposes]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::files:_files' \
&& ret=0
;;
(forward)
_arguments "${_arguments_options[@]}" : \
'-v[Enable logging to stdout, for debugging purposes]' \
'--verbose[Enable logging to stdout, for debugging purposes]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
":: :_wormhole-rs__forward_commands" \
"*::: :->forward" \
&& ret=0

    case $state in
    (forward)
        words=($line[1] "${words[@]}")
        (( CURRENT += 1 ))
        curcontext="${curcontext%:*:*}:wormhole-rs-forward-command-$line[1]:"
        case $line[1] in
            (serve)
_arguments "${_arguments_options[@]}" : \
'*--relay-server=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'*--relay=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'--rendezvous-server=[Use a custom rendezvous server. Both sides need to use the same value in order to find each other]:ws://example.org:_urls' \
'--code=[Enter a code instead of generating one automatically]:CODE:_default' \
'-c+[Length of code (in bytes/words)]:NUMWORDS:_default' \
'--code-length=[Length of code (in bytes/words)]:NUMWORDS:_default' \
'--force-direct[Disable the relay server support and force a direct connection]' \
'(--force-direct)--force-relay[Always route traffic over a relay server. This hides your IP address from the peer (but not from the server operators. Use Tor for that)]' \
'-v[Enable logging to stdout, for debugging purposes]' \
'--verbose[Enable logging to stdout, for debugging purposes]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::targets -- List of ports to open up. You can optionally specify a domain/address to forward remote ports:_hosts' \
&& ret=0
;;
(open)
_arguments "${_arguments_options[@]}" : \
'*--relay-server=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'*--relay=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'--rendezvous-server=[Use a custom rendezvous server. Both sides need to use the same value in order to find each other]:ws://example.org:_urls' \
'--code=[Enter a code instead of generating one automatically]:CODE:_default' \
'-c+[Length of code (in bytes/words)]:NUMWORDS:_default' \
'--code-length=[Length of code (in bytes/words)]:NUMWORDS:_default' \
'--force-direct[Disable the relay server support and force a direct connection]' \
'(--force-direct)--force-relay[Always route traffic over a relay server. This hides your IP address from the peer (but not from the server operators. Use Tor for that)]' \
'-v[Enable logging to stdout, for debugging purposes]' \
'--verbose[Enable logging to stdout, for debugging purposes]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'*::targets -- List of ports to open up. You can optionally specify a domain/address to forward remote ports:_hosts' \
&& ret=0
;;
(connect)
_arguments "${_arguments_options[@]}" : \
'*-p+[Bind to specific ports instead of taking random free high ports. Can be provided multiple times]:PORT:_default' \
'*--port=[Bind to specific ports instead of taking random free high ports. Can be provided multiple times]:PORT:_default' \
'--bind=[Bind to a specific address to accept the forwarding. Depending on your system and firewall, this may make the forwarded ports accessible from the outside]:ADDRESS:' \
'*--relay-server=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'*--relay=[Use a custom relay server (specify multiple times for multiple relays)]:tcp://HOSTNAME:PORT:_urls' \
'--rendezvous-server=[Use a custom rendezvous server. Both sides need to use the same value in order to find each other]:ws://example.org:_urls' \
'--noconfirm[Accept the forwarding without asking for confirmation]' \
'--yes[Accept the forwarding without asking for confirmation]' \
'--force-direct[Disable the relay server support and force a direct connection]' \
'(--force-direct)--force-relay[Always route traffic over a relay server. This hides your IP address from the peer (but not from the server operators. Use Tor for that)]' \
'-v[Enable logging to stdout, for debugging purposes]' \
'--verbose[Enable logging to stdout, for debugging purposes]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
'::code -- Provide the code now rather than typing it interactively:_default' \
&& ret=0
;;
        esac
    ;;
esac
;;
(completion)
_arguments "${_arguments_options[@]}" : \
'-v[Enable logging to stdout, for debugging purposes]' \
'--verbose[Enable logging to stdout, for debugging purposes]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
':shell -- The shell type to generate completions for (bash, elvish, powershell, zsh):(bash elvish fish powershell zsh)' \
&& ret=0
;;
(help)
_arguments "${_arguments_options[@]}" : \
'-v[Enable logging to stdout, for debugging purposes]' \
'--verbose[Enable logging to stdout, for debugging purposes]' \
'-h[Print help]' \
'--help[Print help]' \
'-V[Print version]' \
'--version[Print version]' \
&& ret=0
;;
        esac
    ;;
esac
}

(( $+functions[_wormhole-rs_commands] )) ||
_wormhole-rs_commands() {
    local commands; commands=(
'send:Send a file or a folder' \
'tx:Send a file or a folder' \
'receive:Receive a file or a folder' \
'rx:Receive a file or a folder' \
'send-many:Send a file to many recipients' \
'forward:Forward ports from one machine to another' \
'completion:Generate shell completions for the wormhole CLI' \
'help:' \
    )
    _describe -t commands 'wormhole-rs commands' commands "$@"
}
(( $+functions[_wormhole-rs__completion_commands] )) ||
_wormhole-rs__completion_commands() {
    local commands; commands=()
    _describe -t commands 'wormhole-rs completion commands' commands "$@"
}
(( $+functions[_wormhole-rs__forward_commands] )) ||
_wormhole-rs__forward_commands() {
    local commands; commands=(
'serve:Make the following ports of your system available to your peer' \
'open:Make the following ports of your system available to your peer' \
'connect:Connect to some ports forwarded to you' \
    )
    _describe -t commands 'wormhole-rs forward commands' commands "$@"
}
(( $+functions[_wormhole-rs__forward__connect_commands] )) ||
_wormhole-rs__forward__connect_commands() {
    local commands; commands=()
    _describe -t commands 'wormhole-rs forward connect commands' commands "$@"
}
(( $+functions[_wormhole-rs__forward__serve_commands] )) ||
_wormhole-rs__forward__serve_commands() {
    local commands; commands=()
    _describe -t commands 'wormhole-rs forward serve commands' commands "$@"
}
(( $+functions[_wormhole-rs__help_commands] )) ||
_wormhole-rs__help_commands() {
    local commands; commands=()
    _describe -t commands 'wormhole-rs help commands' commands "$@"
}
(( $+functions[_wormhole-rs__receive_commands] )) ||
_wormhole-rs__receive_commands() {
    local commands; commands=()
    _describe -t commands 'wormhole-rs receive commands' commands "$@"
}
(( $+functions[_wormhole-rs__send_commands] )) ||
_wormhole-rs__send_commands() {
    local commands; commands=()
    _describe -t commands 'wormhole-rs send commands' commands "$@"
}
(( $+functions[_wormhole-rs__send-many_commands] )) ||
_wormhole-rs__send-many_commands() {
    local commands; commands=()
    _describe -t commands 'wormhole-rs send-many commands' commands "$@"
}

if [ "$funcstack[1]" = "_wormhole-rs" ]; then
    _wormhole-rs "$@"
else
    compdef _wormhole-rs wormhole-rs
fi
 }

if [ "$funcstack[1]" = "wormhole-rs" ]; then
   wormhole-rs "$@"
fi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.