Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Rishik-Y
Copy link
Contributor

@Rishik-Y Rishik-Y commented Mar 8, 2025

Implements auto-completion for various shells such as Bash, fish, zsh, powershell, elvish etc

Example:

wayshot - [TAB]
-s                      --extension
-c                      --format
-l                      --output-format
-o                      --encoding
-h                      --list-outputs
-V                      --output
--clipboard             --choose-output
--log-level             --generate-completions
--slurp                 --help
--cursor                --version

or

wayshot --output-format [TAB]
jpg   png   ppm   qoi   webp  

@Rishik-Y Rishik-Y marked this pull request as draft March 8, 2025 19:03
@Rishik-Y
Copy link
Contributor Author

Rishik-Y commented Mar 8, 2025

This is still work in progress (Works fine with Bash but not tested yet with others),
I was unable to figure put what was exactly the conflict when trying to sync no matter how much i try
So figured to directly put it here and leave it to PR to show the conflict directly to me

But If anyone would like to, Do test it out and tell me its flaws :)

@Decodetalkers Decodetalkers marked this pull request as ready for review March 9, 2025 00:31
@Decodetalkers
Copy link
Collaborator

Decodetalkers commented Mar 9, 2025

You can use the function in clap to generate completions, not by writing in hand

For example https://github.com/neocmakelsp/neocmakelsp/blob/master/src%2Fshellcomplete.rs#L1-L16

@Decodetalkers Decodetalkers marked this pull request as draft March 9, 2025 00:40
}
}
None => {
_none => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep it as None

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay 👍️

@Gigas002 Gigas002 mentioned this pull request Mar 10, 2025
@Rishik-Y
Copy link
Contributor Author

Hi @Decodetalkers,
Could you check the code once?
The only issue i seem to face was .bashrc not existing would crash the code,
which was fixed by adding generate .bashrc if doesnt exist.
Other than that I am pretty sure all of them work pretty fine.

@Rishik-Y
Copy link
Contributor Author

There were 2 more shells which we can implement for using clap_complete but skipped,
One being Elvish,
However it seems elvish being pre-1.0 seems to have made some changes which doesnt work with current clap_complete
and powershell,
Which pretty sure works however i cant understand where exactly the completions are being stored since Powershell exists as pkgs for NixOS

@Decodetalkers
Copy link
Collaborator

There were 2 more shells which we can implement for using clap_complete but skipped,
One being Elvish,
However it seems elvish being pre-1.0 seems to have made some changes which doesnt work with current clap_complete
and powershell,
Which pretty sure works however i cant understand where exactly the completions are being stored since Powershell exists as pkgs for NixOS

I think just printing the completions is enough, if we need to install it to some place, we maybe need to think about it more. If just printing, then it is just the job of packagers.

@Rishik-Y Rishik-Y marked this pull request as ready for review March 11, 2025 13:04
@Rishik-Y Rishik-Y marked this pull request as draft March 11, 2025 16:13
@Gigas002
Copy link
Contributor

Side note: clap_complete_nushell can be used for generating nushell completions. It's part of official clap suite too, though I don't know the reasons it's separate from clap_complete

@Rishik-Y
Copy link
Contributor Author

Ahh! Thanks for mentioning this
I Knew clap_complete_nushell existed for nushell but i just roughly saw it via here where it was showcasing as read-only making it turn off for me.
But Thanks for notifying, now that i know that it exists with clap-rs and is maintained,
Will start working on it in a week after my exams get over

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants