click-contrib / click-completion

Add or enhance bash, fish, zsh and powershell completion in Click
MIT License
288 stars 32 forks source link

click 8.0 compatible code? #44

Closed hemna closed 2 years ago

hemna commented 2 years ago

I just asked the click folks if they had a mechanism for automatically showing the shell completion code and installing it, like click-completion has. They said there are no plans to add any mechanism for it. Sad. You can see the issue here: https://github.com/pallets/click/issues/2127

Is there an update to click-completion that outputs click 8.0 compatible shell completion eval code that works? I'm using click 8.0.3 and the completion code generated doesn't work.

Here is a sample

└─> aprsd completion show
#compdef aprsd
_aprsd() {
  eval $(env COMMANDLINE="${words[1,$CURRENT]}" _APRSD_COMPLETE=complete-zsh  aprsd)
}
if [[ "$(basename -- ${(%):-%x})" != "_aprsd" ]]; then
  compdef _aprsd aprsd
fi
╭─aprsd on  master [$!?] via 🐍 v3.8.5 (.venv) ❯
└─> aprsd completion install
zsh completion installed in /Users/i530566/.zshrc

Unfortunately that doesn't work with click 8.0. I updated the code in my ~/.zshrc

eval "$(_APRSD_COMPLETE=zsh_source aprsd)"

and that works.

hemna commented 2 years ago

I added a PR that accomplishes this

https://github.com/click-contrib/click-completion/pull/45

Konubinix commented 2 years ago

Thank you for the pull request :-)

Konubinix commented 2 years ago

Merged the PR