-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(complete): Add dynamic completion for nushell #5841
base: master
Are you sure you want to change the base?
Conversation
Adds an implementation of dynamic completion to `clap_complete_nushell` under the `unstable-dynamic` feature flag. Nushell currently doesn't have a good story for adding what nushell calls "external completers" in a modular fashion. Users can define a single, global external completer. If they wish to combine multiple external completers, they have to manually write a sort of meta-completer that dispatches to the individual completers based on the first argument (the binary). This PR generates a nushell module that offers three commands: - `complete`, which performs the actual completion - `handles`, which asks the module whether it is the correct completer for a particular command line - `install`, which globally registers a completer that falls back to whatever completer was previously installed if `handles` rejects completing a command line. The idea is that user's who already have a custom external completer can integrate the generated module's `handles` and `complete` commands into their completer. Everyone else just puts ```nushell use my-app-completer.nu my-app-completer install ``` into their nushell config.
I do have some questions:
|
For dynamic completions, we focus on the shell integration
etc e.g. see clap/clap_complete/tests/testsuite/bash.rs Lines 242 to 338 in fde45f9
Note that I'm going to focus first on the issue to see if there is any points there ti work out before coming back to the PR to review the implementation. |
re:tests: Thanks! I'll have a look at these. Getting them up and running for nushell should be relatively independent of the concrete implementation.
Yep, let's nail down the conceptual aspects first. |
Adds an implementation of dynamic completion to
clap_complete_nushell
under theunstable-dynamic
feature flag. Corresponding issue #5840. The issue description has more context and a more complete solution sketch. This PR doesn't implement the full solution sketched there. Ideally, we'd first agree that that solution is the way to go.With this PR (and the
unstable-dynamic
feature flag), clap tools can generate a nushell module that offers three commands:complete
, which performs the actual completionhandles
, which asks the module whether it is the correct completer for a particular command lineinstall
, which globally registers a completer that falls back to whatever completer was previously installed ifhandles
rejects completing a command line.The idea is that user's who already have a custom external completer can integrate the generated module's
handles
andcomplete
commands into their completer.Everyone else just puts
into their nushell config.
To test it, I have integrated it into a local build of the relatively complex clap-based tool, JJ (Jujutsu), and it worked very well so far.
TODO