click icon indicating copy to clipboard operation
click copied to clipboard

Support shell completion for nushell

Open LoicRiegel opened this issue 8 months ago • 1 comments

Hi, I'm a contributor of the nushell project, and I think it would be really nice if click was able to generate shells completions for nushell. You can have a look at what custom completions for nushell look like in the nu_script repo, where those cusotm completions were added by the community.

I am up for doing this; although any tip or guidance will be appreciated 😄

LoicRiegel avatar Apr 24 '25 21:04 LoicRiegel

Actually completions are static in nushell. You define and source an "extern" function describing your CLI and that's it, nothing is done at runtime.

Actually all we need is a way to output a string containing the nushell code that the users would then be able to save to a file and source.

Would you consider adding support for static completions in general in click? And nushell would be the first shell using it? Sure it would be possible to create an additionnal python package to add this feature, but this would have to be explicitely installed and setup by the users. Supporting satic completions for nushell natively in click would allow all of the click and typer CLI apps to use this feature out of the box!

LoicRiegel avatar Apr 30 '25 21:04 LoicRiegel

It's great that you want to bring a new shell to Click. I think we are generally open to supporting completion for more shells, but we don't have a way to test shell completion for existing shells. So it's already hard to support our existing shells. I would be willing to consider Nushell if you could help us get some testing in place. I will tag you in the issue.

Rowlando13 avatar Jul 08 '25 03:07 Rowlando13

Sorry, this actually isn't something we want to add directly in Click. I hadn't heard about nushell until this issue, and it's already hard enough to maintain the completions for the "popular" shells. The completion system was revamped to be pluggable, so this would be appropriate for an extension click-nushell. If there's something missing from the public API or completion system that prevents this, that would be good for feature requests.

davidism avatar Jul 08 '25 04:07 davidism

Okay I understand. I didn't know the completion system was made pluggable, though, when did this happen? I'll have a look anyway and try to add click-nushell! When I have time 😄

LoicRiegel avatar Jul 08 '25 08:07 LoicRiegel