-
-
Notifications
You must be signed in to change notification settings - Fork 189
Adds shell completions for lychee #1972
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
base: master
Are you sure you want to change the base?
Conversation
This follows ripgrep's lead and uses the same naming conventions for the CLI args. `clap_complete` does all of the heavy-lifting, so there's no need to write our own generator. Completions get added to the binary releases.
Adds PowerShell, GitHub, IPv4, and IPv6 to the list of valid identifiers to prevent warnings about missing backticks in documentation comments. - Rustdoc configuration in Cargo.toml under [package.metadata.rustdoc] - Clippy configuration in clippy.toml at workspace root
39ff1d8 to
e64b09c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a test file to see if the workflow passes and generates those completion files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we remove this workflow before merging, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes yes
4a0217a to
c765094
Compare
thomas-zahner
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much, cool addition 🚀
I haven't tested it yet. Before merging I would like to do so and update the nix-package accordingly
lychee-bin/complete/_lychee
Outdated
| @@ -0,0 +1,117 @@ | |||
| #compdef lychee | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we shouldn't track any of these files (lychee-bin/complete/* expect readme), as they are generated either manually as described in the docs or via release workflow. Do you agree? We could then also consider moving lychee-bin/complete/README.md to docs/AUTOCOMPLETE.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ripgrep tracks them.. In my opinion, it's great to see the diff for future troubleshooting between versions of clap_complete.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh that surprises me..
Wouldn't we then also need a workflow, a test or some sort of automation to keep these generated files up to date? Otherwise, we constantly forget about keeping these files up-to-date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically yes. That would be a nice addition, but it would also mean some additional work. These things tend to get tricky, especially with committing those files, which might trigger other workflows etc. But it's not strictly necessary in the beginning, in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To expand on that a bit, I believe most people wouldn't care and for the few people who do, they get it out of the box as part of their release builds. We always bundle the latest versions. And the files in the repo are for troubleshooting, for the most part. I could add a make target to update them manually for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that's why personally I would not track those generated files at all. They should always be fully reproducible and as you say they are generated and included with every release. It would be less code, less files and we wouldn't have this problem of outdated files at all.
But if you really prefer to include them for debugging/troubleshooting we can do so.
Also if most people don't care, why should we care to add these files to the repository in the first place? 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be interesting to know why ripgrep tracks them and if they have a mechanism to keep the files up-to-date.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did some research.
-
They don't update the completions through CI, but they added a test to check that the completions are up-to-date, which is quite clever, because it would fail if contributors forget to update the file when new options get added: https://github.com/BurntSushi/ripgrep/blob/master/ci/test-complete
-
One reason (perhaps the only one?) why they track the completion files is that the ZSH completions are handwritten. https://github.com/BurntSushi/ripgrep/blob/0a88cccd5188074de96f54a4b6b44a63971ac157/crates/core/flags/complete/zsh.rs#L4-L5
This way, they get a lot of confidence in their completions with little maintenance overhead. We could do the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added the check
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One reason (perhaps the only one?) why they track the completion files is that the ZSH completions are handwritten.
Ah that would make sense. Then one could argue that we don't need to track them, as we have no customisation or handwritten scripts. Also we could do the new CI shell completion tests by using the output of --generate and not track the generated files. I personally would prefer that. I think tracking the generated files only has any benefit, if we make manual adjustments to those files or if we intend to do so in the future.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So we remove this workflow before merging, right?
|
@thomas-zahner fyi, I tested it on bash, zsh and fish on macOS. Todo before merging:
|
cf110f9 to
ebd3f2b
Compare
ebd3f2b to
d120d40
Compare
|
The completion check makes the build slower (by ~30 seconds) because we have to build the binary first to run |
Thanks for adding the test. You do build specifically for the test script. I don't think this should be necessary. |
|
Good idea. Let's try! |
|
Cool. I've tested it with ZSH and it works perfectly fine. So it's fine to merge from my side. Only my comment about not tracking the generated files which I personally prefer. But I'm also fine with tracking them if you prefer it, or if you think we will soon do some manual adjustments to the scripts. |
|
Yup! That did the trick. Checking completion takes all of 1 second now. Thanks for the tip! |
This follows ripgrep's lead and uses the same naming conventions for the CLI args.
clap_completedoes all the heavy-lifting, so there's no need to write our own generator. Completions get added to the binary releases.@thomas-zahner, I tried to integrate the feature similar to your man page support (thanks for that!).
Also, we should probably update the homebrew recipe after the next release. Example from ripgrep: https://github.com/BurntSushi/ripgrep/blob/0a88cccd5188074de96f54a4b6b44a63971ac157/pkg/brew/ripgrep-bin.rb#L20