-
-
Notifications
You must be signed in to change notification settings - Fork 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
Automatically read license field from Cargo.toml #2144
Conversation
I realized that this PR bump the MSRV to 1.46 or later (since the environment variables where added in this release). Should I use |
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.
Why would this bump MSRV?
Also, please add some tests.
Because cargo < 1.46 doesn't set Looking at the Readme, I found that:
So I think that we should either wait for 2 additional stable releases of rust, or change
I tried to look at the history to know where I should add them, but unfortunately when the macro |
I have created "Rust 1.46" label so that we can look at the issues for it later. |
Good idea |
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 are setting the license, but where exactly is being used?
You also need to rebase on master now.
@robinmoussu Do you plan to pick this up? |
Yes. Sorry the delay. I should have the time this evening. |
I didn't realized that it's possible to specify the license (multiple tests where already doing it), but it doesn't seems possible to use it. This is especially weird in new_help.rs where a |
9e9b4e8
to
8513891
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.
You haven't added a test for crate_license
which would have caught the issue I mentioned in the other comment. Please do.
I am relatively surprised, and I think I totally forgot the context of when I wrote this PR. I thought that the notion of "license" was already exposed in clap, but it seems not. I'm working on it. |
This is a much bigger change than what I expected. And I will not have the time to do it short term. I will finish it (unless someone does it before me) probably in a few months when my current project will no longer have high priority. Here is a list of what is missing:
|
This reverts commit 6898fbd. PR clap-rs#2144 added the `license` field but no consumer has been added since the (like Issue clap-rs#1768). Since this is not ready yet, I am pulling it from the 3.0 release. So far, our main route for pulling a feature from the release has been to put it behind a `unstable-*` feature flag and to create a stablization tracking issue. I chose to instead remove the feature because a write-only field with no effect does not provide values for people to use in as an early access and so doesn't outweight the cost of the extra documentation noise and code noise it creates. Additionally, keeping an `unstable-` feature around when it has such an unknown path (and time table) to stalbization feels like it violates YAGNI. I'm uncertain how much of this feature we can implement and not create a legal trap for users because the crate's license is insufficient for the final artifact's license. I feel our stabliazation process sshould be about iteration and collecting user feedback which this doesn't line up with. When someone is ready to tackle clap-rs#1768, it will be easy to revert this commit and pick up the work again. Fixes clap-rs#3001
Note: this is my first time contributing to clap, and I'm not familiar with the codebase. Please review that I didn't forgot anything.
I recently added support in Cargo for the environment variable CARGO_PKG_LICENSE_FILE in addition to the recently added CARGO_PKG_LICENSE. This commit automatically populate the
license
field by reading those environment variable.If both of the environment variable are empty, should we
panic!()
instead of just returning an empty string? I don't think that panicking is a good idea, since it would possibly break crates that are using theapp_from_crate!
macro, but I don't know of a better way to add a warning.This may help a bit with #1768.