Skip to content
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

[Feature Request] shell completions enhanced #1

Open
yuioto opened this issue Feb 5, 2024 · 3 comments · Fixed by #4
Open

[Feature Request] shell completions enhanced #1

yuioto opened this issue Feb 5, 2024 · 3 comments · Fixed by #4
Assignees
Labels
enhancement New feature or request

Comments

@yuioto
Copy link

yuioto commented Feb 5, 2024

clap support completion, so the cost of adding this feature is very low.

generating at compile-time or generating at runtime, please see: https://docs.rs/clap_complete/latest/clap_complete/

Consider supporting the following shells:

  • nushell
  • powershell
  • zsh
  • bash
  • and more ...

Some links that may be useful:
https://docs.rs/clap_complete_nushell/latest/clap_complete_nushell/

@kingwingfly
Copy link
Owner

kingwingfly commented Feb 5, 2024

I've finished with clap_complete::generate_to aa2a84c in build.rs.

However, the implementation is a little tedious and not easy using. I'll work on searching some more productive methods (maybe learn from git or kubectl).

As so far:

  • unstable-dynamic feature of clap_complete (poor document however)

Edit: Finally, I'd like to follow this example. However, only fish and zsh supported, I'll upload some other auto complete script for bash powershell and so on.

@kingwingfly kingwingfly linked a pull request Feb 5, 2024 that will close this issue
@yuioto
Copy link
Author

yuioto commented Feb 5, 2024

Thanks, it does work.

But it can be better (maybe not the goal), such as:

fav track 

When i press tab, will display the results from fav status -l, only just press enter:

fav track bvid

or

fav track listid

Just like what happens when git switch.

So I think we can keep this issue open.
Maybe you can add an enhanced tag to this issue.

PS: By the way, fav will regard the av number or cid (the id of one of the p in the video) as the bid, then the error will occur.

Maybe I should open a new issue to talk about this problem?

@yuioto yuioto changed the title [Feature request] shell completions [Feature Request] shell completions enhanced Feb 5, 2024
@kingwingfly
Copy link
Owner

kingwingfly commented Feb 5, 2024

This may be called dynamic completion. I feel it's hard to work on. clap-rs/clap#1232

Moreover, I am not very proficient in using the clap_complete crate, its design is so strange and hard to understand with poor documentation, and I don't quite understand how various terminals implement auto-completion. I have not yet completed it, so it's not usable, it cannot do normal easy completion on Windows powershell although works well with fish.

I'll reopen this issue and keep on finding better solution.

@kingwingfly kingwingfly reopened this Feb 5, 2024
@kingwingfly kingwingfly removed a link to a pull request Feb 5, 2024
@kingwingfly kingwingfly self-assigned this Feb 5, 2024
@kingwingfly kingwingfly added the enhancement New feature or request label Feb 5, 2024
@kingwingfly kingwingfly linked a pull request Feb 6, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants