gravitl / netmaker

Netmaker makes networks with WireGuard. Netmaker automates fast, secure, and distributed virtual networks.
https://netmaker.io
Other
9.4k stars 547 forks source link

[Bug]: nmctl completion command not working #2109

Closed nstoik closed 1 year ago

nstoik commented 1 year ago

Contact Details

No response

What happened?

When trying to use the nmctl completion zsh command, it appears the autocomplete file refers to the command as netmaker instead of nmctl and as such, I can't get the autocomplete to work.

I am running this on Ubuntu 22.04 under WSL2 on Windows. I use ZSH and looked primarily at that subcommand in the nmctl tool, but it appears the other shell options behave the same way.

  1. Install nmctl as per the steps in the docs here
  2. Run nmctl completion zsh --help to show the steps to generate the autocomplete script for the zsh shell.
  3. The output help text already refers to the commands as netmaker instead of nmctl
  4. Running the command from the help output to load the completions for each session, netmaker completion zsh > "${fpath[1]}/_netmaker", fails because zsh doesn't have the command netmaker
  5. Changing the command to nmctl completion zsh > "${fpath[1]}/_netmaker" generates the _netmaker file, but a new session does not work correctly for autocompletions.

I suspect the problem is because the name of the command is different but I am not 100% sure. Let me know if there is anything else needed.

Version

v0.17.1

What OS are you using?

Linux

Relevant log output

> nmctl completion zsh --help                                  
Generate the autocompletion script for the zsh shell.

If shell completion is not already enabled in your environment you will need
to enable it.  You can execute the following once:

        echo "autoload -U compinit; compinit" >> ~/.zshrc

To load completions in your current shell session:

        source <(netmaker completion zsh); compdef _netmaker netmaker

To load completions for every new session, execute once:

#### Linux:

        netmaker completion zsh > "${fpath[1]}/_netmaker"

#### macOS:

        netmaker completion zsh > $(brew --prefix)/share/zsh/site-functions/_netmaker

You will need to start a new shell for this setup to take effect.

Usage:
  netmaker completion zsh [flags]

Flags:
  -h, --help              help for zsh
      --no-descriptions   disable completion descriptions

Contributing guidelines

nstoik commented 1 year ago

Tested this again on v0.20.0 and the autocomplete with zsh is now working!