feat(no_cargo): add no_cargo feature to disable Cargo-env-var-dependent macros (#786)

This commit is contained in:
Jędrzej 2016-12-28 03:07:59 +01:00 committed by Kevin K
parent eb1d79dbb1
commit 6fdd2f9d69
3 changed files with 5 additions and 2 deletions

View file

@ -39,6 +39,7 @@ unstable = [] # for building with unstable clap features (doesn't require nig
nightly = [] # for building with unstable Rust features (currently none)
lints = ["clippy"] # Requires nightly Rust
debug = [] # Enables debug messages
no_cargo = [] # Enable if you're not using Cargo, disables Cargo-env-var-dependent macros
[profile.release]
opt-level = 3

View file

@ -104,8 +104,8 @@ impl<'a, 'b> App<'a, 'b> {
#[deprecated(since="2.14.1", note="Can never work; use explicit App::author() and App::version() calls instead")]
pub fn with_defaults<S: Into<String>>(n: S) -> Self {
let mut a = App { p: Parser::with_name(n.into()) };
a.p.meta.author = Some(crate_authors!());
a.p.meta.version = Some(crate_version!());
a.p.meta.author = Some("Kevin K. <kbknapp@gmail.com>");
a.p.meta.version = Some("2.19.2");
a
}

View file

@ -385,6 +385,7 @@ macro_rules! arg_enum {
/// .get_matches();
/// # }
/// ```
#[cfg(not(feature="no_cargo"))]
#[macro_export]
macro_rules! crate_version {
() => {
@ -413,6 +414,7 @@ macro_rules! crate_version {
/// .get_matches();
/// # }
/// ```
#[cfg(not(feature="no_cargo"))]
#[macro_export]
macro_rules! crate_authors {
($sep:expr) => {{