nix-community / comma

Comma runs software without installing it. [maintainers=@Artturin,@burke,@DavHau]
1.01k stars 47 forks source link

Add Zsh completion #65

Closed ambroisie closed 3 months ago

ambroisie commented 8 months ago

Closes #54 (only for Zsh, as that's the one I use).

Artturin commented 8 months ago

Using https://docs.rs/clap_complete/latest/clap_complete/ would be nicer and would support more shells (bash,elvish,fish,powershell,zsh)

https://github.com/clap-rs/clap/tree/master/clap_complete/examples

https://github.com/NixOS/nixpkgs/blob/eecc84500f0dc82f3b8b852a55dff494578766a2/pkgs/tools/misc/onefetch/default.nix#L50-L55

ambroisie commented 8 months ago

Yeah but does it know how to auto-complete for sudo-like command wrappers? I couldn't find it in the docs.

Artturin commented 8 months ago

Maybe https://docs.rs/clap/latest/clap/enum.ValueHint.html#variant.CommandWithArguments

https://github.com/clap-rs/clap/blob/14fd853fb9c5b94e371170bbd0ca2bf28ef3abff/clap_complete/examples/completion-derive.rs#L56-L58

https://github.com/search?q=%2FValueHint%3A%3ACommandWithArguments%2F+lang%3Arust+NOT+is%3Afork&type=code

https://github.com/clap-rs/clap/blob/14fd853fb9c5b94e371170bbd0ca2bf28ef3abff/clap_complete/src/shells/zsh.rs#L408

https://github.com/clap-rs/clap/blob/14fd853fb9c5b94e371170bbd0ca2bf28ef3abff/clap_complete/tests/snapshots/value_hint.zsh#L40

ambroisie commented 8 months ago

Ah nice, I was looking for _command_names.