Skip to content

Commit

Permalink
Merge pull request #3531 from epage/feature
Browse files Browse the repository at this point in the history
fix: Reduce chance of missing `cargo` feature
  • Loading branch information
epage authored Mar 3, 2022
2 parents d2863a2 + c6d456f commit 4955929
Show file tree
Hide file tree
Showing 18 changed files with 44 additions and 1 deletion.
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,6 @@ required-features = ["cargo"]
[[example]]
name = "02_apps"
path = "examples/tutorial_builder/02_apps.rs"
required-features = ["cargo"]

[[example]]
name = "02_crate"
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/01_quick.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command, Command};
use std::path::Path;

Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/02_app_settings.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command, AppSettings};

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/02_crate.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command};

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/03_01_flag_bool.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command};

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/03_01_flag_count.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command};

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/03_02_option.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command};

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/03_03_positional.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command};

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/03_04_subcommands.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command, Command};

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/03_05_default_values.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command};

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/04_01_enum.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command, ArgEnum, PossibleValue};

#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ArgEnum)]
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/04_01_possible.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command};

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/04_02_parse.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command};

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/04_02_validate.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command};
use std::ops::RangeInclusive;
use std::str::FromStr;
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/04_03_relations.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command, ArgGroup};

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/04_04_custom.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command, ErrorKind};

fn main() {
Expand Down
2 changes: 2 additions & 0 deletions examples/tutorial_builder/05_01_assert.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Note: this requires the `cargo` feature

use clap::{arg, command};

fn main() {
Expand Down
12 changes: 12 additions & 0 deletions src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,18 @@ macro_rules! command {
}};
}

/// Requires `cargo` feature flag to be enabled.
#[cfg(not(feature = "cargo"))]
#[macro_export]
macro_rules! command {
() => {{
compile_error!("`cargo` feature flag is required");
}};
($name:expr) => {{
compile_error!("`cargo` feature flag is required");
}};
}

/// Deprecated, replaced with [`clap::command!`][crate::command]
#[cfg(feature = "cargo")]
#[deprecated(since = "3.1.0", note = "Replaced with `clap::command!")]
Expand Down

0 comments on commit 4955929

Please sign in to comment.