From 6fdd2f9d693aaf1118fc61bd362273950703f43d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej?= Date: Wed, 28 Dec 2016 03:07:59 +0100 Subject: [PATCH] feat(no_cargo): add no_cargo feature to disable Cargo-env-var-dependent macros (#786) --- Cargo.toml | 1 + src/app/mod.rs | 4 ++-- src/macros.rs | 2 ++ 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 812cfd4e4f8..d1176b24249 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 diff --git a/src/app/mod.rs b/src/app/mod.rs index b3139e03503..7690133a239 100644 --- a/src/app/mod.rs +++ b/src/app/mod.rs @@ -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>(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. "); + a.p.meta.version = Some("2.19.2"); a } diff --git a/src/macros.rs b/src/macros.rs index 62fabf68156..d734bade05a 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -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) => {{