Skip to content

Export licence and licence-field in environment variable #8024

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
robinmoussu opened this issue Mar 21, 2020 · 0 comments · Fixed by #8325
Closed

Export licence and licence-field in environment variable #8024

robinmoussu opened this issue Mar 21, 2020 · 0 comments · Fixed by #8325
Labels
A-environment-variables Area: environment variables C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

Comments

@robinmoussu
Copy link
Contributor

robinmoussu commented Mar 21, 2020

Before starting, please stop me if it is possible to access to the licence or licence-field when compiling with cargo.

Describe the problem you are trying to solve

Access licence and licence-field when compiling a rust program with cargo.

Describe the solution you'd like

I think it should be through environment variable to be consistent with the other exported variables (like author, version, …) of the manifest. I don't think it is necessary to be able to recursively access to the version of the dependencies, at least for a first version.

Why do I want to access them

I was trying to create a help message to my program using clap. The default generated help message is nice, but I noticed that it didn't included information about the licence of my software, even using the app_from_crate macro. I wanted to add it, and thus looked at the implementation of that macro. I saw that it was accessing its information (the author name, the name of the application, the version, …) from environment variables exported by cargo. I then looked at the cargo documentation and saw than neither the licence nor licence-field was exported. Since crate.io requires that either must be set, I think that there is a high chance to have one of those filed, and it could be useful to be able to access them.

Note: Having the licence visible in the help message make it easy to export it in a man page through help2man.

Notes

I will try to look at the issue myself. I may need some guidance though.

@robinmoussu robinmoussu added the C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` label Mar 21, 2020
@ehuss ehuss added the A-environment-variables Area: environment variables label Mar 24, 2020
bors added a commit that referenced this issue Jun 20, 2020
… r=joshtriplett

Adding environment variable CARGO_PKG_LICENSE

Fixes #8024
@bors bors closed this as completed in 4a4f5a2 Jun 20, 2020
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
A-environment-variables Area: environment variables C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants