-
Notifications
You must be signed in to change notification settings - Fork 51
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
Generate completions at compile-time #118
Conversation
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.
Hey, sounds like a good idea :) Couple points added in comments.
- Can you make a release on your repo to see the result of the run?
When I was debugging workflows, I found that I had to turn on Settings > Code and automation > Actions > General > Workflow permissions > Read and write permission. Did you turn off it? Or is this the default setting for every new fork repository?
It's on for this repo and I don't think I messed with it, maybe they changed the default 🤷
Please refer to https://github.com/TD-Sky/dotter/actions/runs/4564049786 . I set the workflow running event to push tags. Now we can use |
What happens to the uploaded assets if a tag is created without a release? |
Did you mean you dislike releasing on tag created? Once the tag is created, the action will definitely start and create new assets. |
but will they be uploaded and attached to the Release? I assume that if I create a release+tag at the same time then it will work, but I'm wondering about a tag only since you're suggesting it |
Certainly yes, that is what I've always done in my project. |
46126bc
to
e5cfb14
Compare
Done. Release sample: https://github.com/TD-Sky/dotter/releases/tag/v0.13.2 Corresponding github action: https://github.com/TD-Sky/dotter/actions/runs/4586731786 |
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.
Looks good! Are the completions supposed to be checked into the repo? If they are generated I feel like it should be gitignored.
Also please fix CI fails :)
I think there are no any strict standards about whether to track completion files. So ignoring them is OK. The clippy failure came from the old codes. Are you sure letting me fix it? |
The warning comes from the Make sure to first remove the files then gitignore, git makes this annoying |
Done. |
README.md
Outdated
@@ -48,7 +48,6 @@ Commands: | |||
undeploy Delete all deployed files from their target locations. Note that this operates on all files that are currently in cache | |||
init Initialize global.toml with a single package containing all the files in the current directory pointing to a dummy value and a local.toml that selects that package | |||
watch Run continuously, watching the repository for changes and deploying as soon as they happen. Can be ran with `--dry-run` | |||
gen-completions Generate shell completions |
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.
needs revert
dotter is using packages that are going to be out of date |
yeah that's because of |
Sorry, I didn't see the Error below. The crate |
I track the crate in the project with |
https://lib.rs/crates/exmex found those with a quick search. I appreciate the help with the warning but let's split that into a separate PR (it's already mentioned in #110 too) |
OK, I got it. |
Thanks for the contribution <3 I'll make a release later today |
This reverts commit fd4ef23.
(ignore revert, misclick) Seems like Found this out using |
@TD-Sky not sure if you're getting pinged since the PR is closed, I tried searching for a solution but I'm not sure what to do about this... Maybe we can ditch the build.rs and instead run |
@SuperCuber
I found didyoumean also ignores the compile-time generated files. But they publish to crates.io successfully! Let me ask how they do that. |
If one PR is closed, the participants would not receive the new comments unless they are @. |
@TD-Sky Yeah, strange how it works for them. Maybe they use
I meant calling it in publish CI job and then uploading it to the release, but at packing stage is also an option. |
@SuperCuber The author of didyoumean has been inactive for a long time (the last activity is at the end of last year).
I guess you are right. He didn't make a CI for Now there are two solutions:
However, I don't understand why orhun only generates completions for |
@TD-Sky I just noticed that I did not get a notification for your message 🤦 i think generating in CI is the best approach. Let's see if the Revert button on the PR works :) |
This reverts commit fd4ef23.
There are two ways to generate completions in clap:
build.rs
at compile-time.I observe that some projects didn't add completion scripts generation at the beginning. So when they wanted to generate completion scripts at compile-time, they would face a tough work of bringing types related to the command parser all together. At this point, they tend to choose the runtime generation.
Therefore, I rewrite the generation to run in compile-time as
dotter
doesn't have the difficulties above. At the same time I refactor the workflows to pack completion scripts and binary together. If this PR passes, I will make new PKGBUILD and pull request to orhun.When I was debugging workflows, I found that I had to turn on
Settings > Code and automation > Actions > General > Workflow permissions > Read and write permission
. Did you turn off it? Or is this the default setting for every new fork repository?