Skip to content
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

docs: Present other environment variable alternatives to crate_name! #4514

Merged
merged 1 commit into from
Jan 3, 2023

Conversation

noritada
Copy link
Contributor

This PR will add a note to the description on crate_name! macro about where the name in the output come from.

There are 3 name-related environment variables in cargo, CARGO_PKG_NAME, CARGO_CRATE_NAME, and CARGO_BIN_NAME, and the crate_name! macro uses the 1st one among them. This means that foo is used as the name in the case of Cargo.toml as shown below:

[package]
name = "foo"

[[bin]]
name = "bar"

Since the crate_* macros are under consideration for deprecation in #2840, and changing the source to another environment variable would result in the behavior change, I think it would be best to add a note to the documentation.

If you have suggestions, I would appreciate it.
Thank you very much.

`crate_name!` macro uses a value of an environment variable
`CARGO_PKG_NAME`, but there are other similar variables
`CARGO_PKG_NAME` and `CARGO_CRATE_NAME`, that users should be aware of.
@noritada noritada changed the title docs: present CARGO_CRATE_NAME and CARGO_BIN_NAME as alternatives to crate_name! docs: Present CARGO_CRATE_NAME and CARGO_BIN_NAME as alternatives to crate_name! Nov 27, 2022
@noritada noritada force-pushed the notes-on-cargo-env-vars branch 2 times, most recently from 56e7db7 to b3ef28c Compare November 27, 2022 16:27
@noritada noritada changed the title docs: Present CARGO_CRATE_NAME and CARGO_BIN_NAME as alternatives to crate_name! docs: Present other environment variable alternatives to crate_name! Nov 27, 2022
@epage
Copy link
Member

epage commented Jan 3, 2023

Thanks!

@epage epage merged commit 7229047 into clap-rs:master Jan 3, 2023
@noritada noritada deleted the notes-on-cargo-env-vars branch January 4, 2023 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants