mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
commit
d45ed909f6
168 changed files with 154 additions and 142 deletions
|
@ -119,8 +119,9 @@ backtrace = { version = "0.3", optional = true }
|
|||
[dev-dependencies]
|
||||
regex = "1.0"
|
||||
lazy_static = "1"
|
||||
version-sync = "0.9"
|
||||
criterion = "0.3.2"
|
||||
trybuild = "1.0"
|
||||
rustversion = "1"
|
||||
# Cutting out `filesystem` feature
|
||||
trycmd = { version = "0.8.0", default-features = false, features = ["color-auto", "diff", "examples"] }
|
||||
|
||||
|
|
1
Makefile
1
Makefile
|
@ -26,3 +26,4 @@ build-%:
|
|||
|
||||
test-%:
|
||||
cargo test ${_FEATURES_${@:test-%=%}} --all-targets ${ARGS}
|
||||
cargo test ${_FEATURES_${@:test-%=%}} --doc ${ARGS}
|
||||
|
|
|
@ -40,9 +40,6 @@ proc-macro-error = "1"
|
|||
|
||||
[dev-dependencies]
|
||||
clap = { path = "../", default-features = false, features = ["std", "derive", "env"] }
|
||||
trybuild = "1.0"
|
||||
rustversion = "1"
|
||||
version-sync = "0.9"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
|
|
|
@ -35,7 +35,6 @@ clap = { path = "../", version = "=3.0.0-beta.5", default-features = false, feat
|
|||
|
||||
[dev-dependencies]
|
||||
pretty_assertions = "1.0"
|
||||
version-sync = "0.9"
|
||||
clap = { path = "../", version = "=3.0.0-beta.5", default-features = false, features = ["std", "derive"] }
|
||||
|
||||
[features]
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
//! fn build_cli() -> App<'static> {
|
||||
//! App::new("example")
|
||||
//! .arg(Arg::new("file")
|
||||
//! .about("some input file")
|
||||
//! .help("some input file")
|
||||
//! .value_hint(ValueHint::AnyPath),
|
||||
//! )
|
||||
//! .arg(
|
||||
|
@ -104,13 +104,13 @@ pub use shell::Shell;
|
|||
/// App::new("compl")
|
||||
/// .about("Tests completions")
|
||||
/// .arg(Arg::new("file")
|
||||
/// .about("some input file"))
|
||||
/// .help("some input file"))
|
||||
/// .subcommand(App::new("test")
|
||||
/// .about("tests things")
|
||||
/// .arg(Arg::new("case")
|
||||
/// .long("case")
|
||||
/// .takes_value(true)
|
||||
/// .about("the case to test")))
|
||||
/// .help("the case to test")))
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
use version_sync::assert_html_root_url_updated;
|
||||
|
||||
#[test]
|
||||
fn test_html_root_url() {
|
||||
assert_html_root_url_updated!("src/lib.rs");
|
||||
}
|
|
@ -2036,7 +2036,7 @@ impl<'help> Arg<'help> {
|
|||
/// // value with a help text
|
||||
/// PossibleValue::new("slow").help("not that fast"),
|
||||
/// // value that is hidden from completion and help text
|
||||
/// PossibleValue::new("medium").hidden(true),
|
||||
/// PossibleValue::new("medium").hide(true),
|
||||
/// ])
|
||||
/// # ;
|
||||
/// ```
|
||||
|
@ -2113,7 +2113,7 @@ impl<'help> Arg<'help> {
|
|||
/// // value with a help text
|
||||
/// .possible_value(PossibleValue::new("slow").help("not that fast"))
|
||||
/// // value that is hidden from completion and help text
|
||||
/// .possible_value(PossibleValue::new("medium").hidden(true))
|
||||
/// .possible_value(PossibleValue::new("medium").hide(true))
|
||||
/// # ;
|
||||
/// ```
|
||||
///
|
||||
|
@ -3956,7 +3956,7 @@ impl<'help> Arg<'help> {
|
|||
/// let m = App::new("prog")
|
||||
/// .arg(Arg::new("cfg")
|
||||
/// .long("config")
|
||||
/// .hidden(true)
|
||||
/// .hide(true)
|
||||
/// .help("Some help text describing the --config arg"))
|
||||
/// .get_matches_from(vec![
|
||||
/// "prog", "--help"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{arg, App, AppSettings, Arg, ErrorKind};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{arg, App, Arg};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{arg, App, Arg};
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
mod utils;
|
||||
|
||||
use clap::{Arg, ArgSettings};
|
||||
|
||||
#[test]
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{arg, App, Arg, ArgGroup, ErrorKind};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
use clap::{arg, App, Arg, ErrorKind};
|
||||
|
||||
#[test]
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use std::str;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::App;
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{App, Arg, ErrorKind};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{App, Arg, Error, ErrorKind};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{arg, App, AppSettings, Arg, ErrorKind};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
use clap::{arg, App, Arg};
|
||||
|
||||
const USE_FLAG_AS_ARGUMENT: &str =
|
|
@ -1,5 +1,3 @@
|
|||
mod utils;
|
||||
|
||||
use clap::{arg, App, Arg};
|
||||
|
||||
#[test]
|
|
@ -1,7 +1,5 @@
|
|||
#![cfg(feature = "unstable-grouped")]
|
||||
|
||||
mod utils;
|
||||
|
||||
use clap::{App, AppSettings, Arg};
|
||||
|
||||
#[test]
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{arg, App, Arg, ArgGroup, ErrorKind};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{arg, App, AppSettings, Arg, ArgGroup, ErrorKind, PossibleValue};
|
||||
|
|
@ -4,7 +4,7 @@ use std::env;
|
|||
|
||||
use clap::{App, Arg};
|
||||
|
||||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
static HIDE_ENV: &str = "ctest 0.1
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{arg, App, AppSettings, Arg};
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
mod utils;
|
||||
|
||||
use clap::{App, Arg};
|
||||
|
||||
#[test]
|
47
tests/builder/main.rs
Normal file
47
tests/builder/main.rs
Normal file
|
@ -0,0 +1,47 @@
|
|||
mod app_from_crate;
|
||||
mod app_settings;
|
||||
mod arg_aliases;
|
||||
mod arg_aliases_short;
|
||||
mod arg_matcher_assertions;
|
||||
mod arg_settings;
|
||||
mod borrowed;
|
||||
mod cargo;
|
||||
mod conflicts;
|
||||
mod default_missing_vals;
|
||||
mod default_vals;
|
||||
mod delimiters;
|
||||
mod derive_order;
|
||||
mod display_order;
|
||||
mod double_require;
|
||||
mod empty_values;
|
||||
mod env;
|
||||
mod error;
|
||||
mod flag_subcommands;
|
||||
mod flags;
|
||||
mod global_args;
|
||||
mod grouped_values;
|
||||
mod groups;
|
||||
mod help;
|
||||
mod help_env;
|
||||
mod hidden_args;
|
||||
mod ignore_errors;
|
||||
mod indices;
|
||||
mod multiple_occurrences;
|
||||
mod multiple_values;
|
||||
mod opts;
|
||||
mod positionals;
|
||||
mod posix_compatible;
|
||||
mod possible_values;
|
||||
mod propagate_globals;
|
||||
mod regex;
|
||||
mod require;
|
||||
mod subcommands;
|
||||
mod template_help;
|
||||
mod tests;
|
||||
mod unicode;
|
||||
mod unique_args;
|
||||
mod utf16;
|
||||
mod utf8;
|
||||
mod utils;
|
||||
mod validators;
|
||||
mod version;
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{arg, App, AppSettings, Arg, ArgMatches, ErrorKind};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{App, Arg, ErrorKind, PossibleValue};
|
||||
|
|
@ -1,5 +1,3 @@
|
|||
mod utils;
|
||||
|
||||
use clap::{App, Arg, ArgMatches};
|
||||
|
||||
fn get_app() -> App<'static> {
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{arg, App, Arg, ArgGroup, ErrorKind};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{arg, App, AppSettings, Arg, ErrorKind};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{arg, App};
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use std::io::Write;
|
||||
use std::str;
|
|
@ -1,4 +1,4 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use std::str;
|
||||
|
|
@ -12,10 +12,9 @@
|
|||
// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the
|
||||
// MIT/Apache 2.0 license.
|
||||
|
||||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::Parser;
|
||||
use utils::*;
|
||||
|
||||
#[test]
|
||||
fn no_author_version_about() {
|
||||
|
@ -23,7 +22,7 @@ fn no_author_version_about() {
|
|||
#[clap(name = "foo")]
|
||||
struct Opt {}
|
||||
|
||||
let output = get_long_help::<Opt>();
|
||||
let output = utils::get_long_help::<Opt>();
|
||||
assert!(output.starts_with("foo \n\nUSAGE:"));
|
||||
}
|
||||
|
||||
|
@ -33,10 +32,11 @@ fn use_env() {
|
|||
#[clap(author, about, version)]
|
||||
struct Opt {}
|
||||
|
||||
let output = get_long_help::<Opt>();
|
||||
assert!(output.starts_with("clap_derive"));
|
||||
assert!(output.contains("Guillaume Pinot <texitoi@texitoi.eu>, Clap Maintainers"));
|
||||
assert!(output.contains("Parse command line argument by defining a struct, derive crate"));
|
||||
let output = utils::get_long_help::<Opt>();
|
||||
assert!(output.starts_with("clap"));
|
||||
assert!(output.contains("Kevin K. <kbknapp@gmail.com>, Clap Maintainers"));
|
||||
assert!(output
|
||||
.contains("A simple to use, efficient, and full-featured Command Line Argument Parser"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -47,6 +47,6 @@ fn explicit_version_not_str_lit() {
|
|||
#[clap(version = VERSION)]
|
||||
pub struct Opt {}
|
||||
|
||||
let output = get_long_help::<Opt>();
|
||||
let output = utils::get_long_help::<Opt>();
|
||||
assert!(output.contains("custom version"));
|
||||
}
|
|
@ -1,8 +1,6 @@
|
|||
use clap::Parser;
|
||||
|
||||
mod utils;
|
||||
|
||||
use utils::*;
|
||||
use crate::utils;
|
||||
|
||||
#[test]
|
||||
fn default_value() {
|
||||
|
@ -14,7 +12,7 @@ fn default_value() {
|
|||
assert_eq!(Opt { arg: 3 }, Opt::try_parse_from(&["test"]).unwrap());
|
||||
assert_eq!(Opt { arg: 1 }, Opt::try_parse_from(&["test", "1"]).unwrap());
|
||||
|
||||
let help = get_long_help::<Opt>();
|
||||
let help = utils::get_long_help::<Opt>();
|
||||
assert!(help.contains("[default: 3]"));
|
||||
}
|
||||
|
||||
|
@ -28,7 +26,7 @@ fn default_value_t() {
|
|||
assert_eq!(Opt { arg: 3 }, Opt::try_parse_from(&["test"]).unwrap());
|
||||
assert_eq!(Opt { arg: 1 }, Opt::try_parse_from(&["test", "1"]).unwrap());
|
||||
|
||||
let help = get_long_help::<Opt>();
|
||||
let help = utils::get_long_help::<Opt>();
|
||||
assert!(help.contains("[default: 3]"));
|
||||
}
|
||||
|
||||
|
@ -42,6 +40,6 @@ fn auto_default_value_t() {
|
|||
assert_eq!(Opt { arg: 0 }, Opt::try_parse_from(&["test"]).unwrap());
|
||||
assert_eq!(Opt { arg: 1 }, Opt::try_parse_from(&["test", "1"]).unwrap());
|
||||
|
||||
let help = get_long_help::<Opt>();
|
||||
let help = utils::get_long_help::<Opt>();
|
||||
assert!(help.contains("[default: 0]"));
|
||||
}
|
|
@ -12,10 +12,9 @@
|
|||
// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the
|
||||
// MIT/Apache 2.0 license.
|
||||
|
||||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{ArgEnum, Parser};
|
||||
use utils::*;
|
||||
|
||||
#[test]
|
||||
fn doc_comments() {
|
||||
|
@ -28,7 +27,7 @@ fn doc_comments() {
|
|||
foo: bool,
|
||||
}
|
||||
|
||||
let help = get_long_help::<LoremIpsum>();
|
||||
let help = utils::get_long_help::<LoremIpsum>();
|
||||
assert!(help.contains("Lorem ipsum"));
|
||||
assert!(help.contains("Fooify a bar and a baz"));
|
||||
}
|
||||
|
@ -44,7 +43,7 @@ fn help_is_better_than_comments() {
|
|||
foo: bool,
|
||||
}
|
||||
|
||||
let help = get_long_help::<LoremIpsum>();
|
||||
let help = utils::get_long_help::<LoremIpsum>();
|
||||
assert!(help.contains("Dolor sit amet"));
|
||||
assert!(!help.contains("Lorem ipsum"));
|
||||
assert!(help.contains("DO NOT PASS A BAR"));
|
||||
|
@ -59,7 +58,7 @@ fn empty_line_in_doc_comment_is_double_linefeed() {
|
|||
#[clap(name = "lorem-ipsum")]
|
||||
struct LoremIpsum {}
|
||||
|
||||
let help = get_long_help::<LoremIpsum>();
|
||||
let help = utils::get_long_help::<LoremIpsum>();
|
||||
assert!(help.starts_with("lorem-ipsum \n\nFoo.\n\nBar\n\nUSAGE:"));
|
||||
}
|
||||
|
||||
|
@ -80,8 +79,8 @@ fn field_long_doc_comment_both_help_long_help() {
|
|||
bar: bool,
|
||||
}
|
||||
|
||||
let short_help = get_help::<LoremIpsum>();
|
||||
let long_help = get_long_help::<LoremIpsum>();
|
||||
let short_help = utils::get_help::<LoremIpsum>();
|
||||
let long_help = utils::get_long_help::<LoremIpsum>();
|
||||
|
||||
assert!(short_help.contains("Dot is removed from one short comment"));
|
||||
assert!(!short_help.contains("Dot is removed from one short comment."));
|
||||
|
@ -112,8 +111,8 @@ fn top_long_doc_comment_both_help_long_help() {
|
|||
},
|
||||
}
|
||||
|
||||
let short_help = get_help::<LoremIpsum>();
|
||||
let long_help = get_subcommand_long_help::<LoremIpsum>("foo");
|
||||
let short_help = utils::get_help::<LoremIpsum>();
|
||||
let long_help = utils::get_subcommand_long_help::<LoremIpsum>("foo");
|
||||
|
||||
assert!(!short_help.contains("Or something else"));
|
||||
assert!(long_help.contains("DO NOT PASS A BAR UNDER ANY CIRCUMSTANCES"));
|
||||
|
@ -146,7 +145,7 @@ fn verbatim_doc_comment() {
|
|||
foo: bool,
|
||||
}
|
||||
|
||||
let help = get_long_help::<SeeFigure1>();
|
||||
let help = utils::get_long_help::<SeeFigure1>();
|
||||
let sample = r#"
|
||||
()
|
||||
|
|
||||
|
@ -179,7 +178,7 @@ fn verbatim_doc_comment_field() {
|
|||
bar: bool,
|
||||
}
|
||||
|
||||
let help = get_long_help::<App>();
|
||||
let help = utils::get_long_help::<App>();
|
||||
|
||||
assert!(help.contains("This help ends in a period."));
|
||||
assert!(help.contains("This help does not end in a period"));
|
||||
|
@ -196,12 +195,12 @@ fn multiline_separates_default() {
|
|||
x: String,
|
||||
}
|
||||
|
||||
let help = get_long_help::<App>();
|
||||
let help = utils::get_long_help::<App>();
|
||||
assert!(!help.contains("Doc comment [default"));
|
||||
assert!(help.lines().any(|s| s.trim().starts_with("[default")));
|
||||
|
||||
// The short help should still have the default on the same line
|
||||
let help = get_help::<App>();
|
||||
let help = utils::get_help::<App>();
|
||||
assert!(help.contains("Multiline [default"));
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::Parser;
|
||||
use utils::*;
|
||||
|
||||
#[test]
|
||||
fn explicit_short_long_no_rename() {
|
||||
|
@ -32,6 +31,6 @@ fn explicit_name_no_rename() {
|
|||
foo: String,
|
||||
}
|
||||
|
||||
let help = get_long_help::<Opt>();
|
||||
let help = utils::get_long_help::<Opt>();
|
||||
assert!(help.contains("<.options>"))
|
||||
}
|
|
@ -12,10 +12,9 @@
|
|||
// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the
|
||||
// MIT/Apache 2.0 license.
|
||||
|
||||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{Args, Parser, Subcommand};
|
||||
use utils::get_help;
|
||||
|
||||
#[test]
|
||||
fn flatten() {
|
||||
|
@ -231,7 +230,7 @@ fn docstrings_ordering_with_multiple_clap() {
|
|||
flattened: Flattened,
|
||||
}
|
||||
|
||||
let short_help = get_help::<Command>();
|
||||
let short_help = utils::get_help::<Command>();
|
||||
|
||||
assert!(short_help.contains("This is the docstring for Command"));
|
||||
}
|
||||
|
@ -251,7 +250,7 @@ fn docstrings_ordering_with_multiple_clap_partial() {
|
|||
flattened: Flattened,
|
||||
}
|
||||
|
||||
let short_help = get_help::<Command>();
|
||||
let short_help = utils::get_help::<Command>();
|
||||
|
||||
assert!(short_help.contains("This is the docstring for Flattened"));
|
||||
}
|
|
@ -1,5 +1,3 @@
|
|||
mod utils;
|
||||
|
||||
use clap::{Args, Parser};
|
||||
|
||||
#[test]
|
|
@ -221,8 +221,8 @@ fn derive_generated_error_has_full_context() {
|
|||
let expected = r#"error: The following required argument was not provided: req-str
|
||||
|
||||
USAGE:
|
||||
clap_derive --req-str <REQ_STR>
|
||||
clap_derive <SUBCOMMAND>
|
||||
clap --req-str <REQ_STR>
|
||||
clap <SUBCOMMAND>
|
||||
|
||||
For more information try --help
|
||||
"#;
|
|
@ -1,7 +1,6 @@
|
|||
// https://github.com/TeXitoi/structopt/issues/{NUMBER}
|
||||
|
||||
mod utils;
|
||||
use utils::*;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{AppSettings, ArgGroup, Args, Parser, Subcommand};
|
||||
|
||||
|
@ -71,7 +70,7 @@ fn issue_324() {
|
|||
Start,
|
||||
}
|
||||
|
||||
let help = get_long_help::<Opt>();
|
||||
let help = utils::get_long_help::<Opt>();
|
||||
assert!(help.contains("MY_VERSION"));
|
||||
}
|
||||
|
||||
|
@ -97,7 +96,7 @@ fn issue_418() {
|
|||
Frobnicate,
|
||||
}
|
||||
|
||||
let help = get_long_help::<Opts>();
|
||||
let help = utils::get_long_help::<Opts>();
|
||||
assert!(help.contains("Reticulate the splines [aliases: ret]"));
|
||||
}
|
||||
|
31
tests/derive/main.rs
Normal file
31
tests/derive/main.rs
Normal file
|
@ -0,0 +1,31 @@
|
|||
#![cfg(feature = "derive")]
|
||||
|
||||
mod app_name;
|
||||
mod arg_enum;
|
||||
mod argument_naming;
|
||||
mod arguments;
|
||||
mod author_version_about;
|
||||
mod basic;
|
||||
mod boxed;
|
||||
mod custom_string_parsers;
|
||||
mod default_value;
|
||||
mod deny_warnings;
|
||||
mod doc_comments_help;
|
||||
mod explicit_name_no_renaming;
|
||||
mod flags;
|
||||
mod flatten;
|
||||
mod generic;
|
||||
mod help;
|
||||
mod issues;
|
||||
mod macros;
|
||||
mod nested_subcommands;
|
||||
mod non_literal_attributes;
|
||||
mod options;
|
||||
mod privacy;
|
||||
mod raw_bool_literal;
|
||||
mod raw_idents;
|
||||
mod rename_all_env;
|
||||
mod skip;
|
||||
mod subcommands;
|
||||
mod utf8;
|
||||
mod utils;
|
|
@ -14,10 +14,9 @@
|
|||
|
||||
#![allow(clippy::option_option)]
|
||||
|
||||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{Parser, Subcommand};
|
||||
use utils::*;
|
||||
|
||||
#[test]
|
||||
fn required_option() {
|
||||
|
@ -199,7 +198,7 @@ fn option_option_type_help() {
|
|||
#[clap(long, value_name = "val")]
|
||||
arg: Option<Option<i32>>,
|
||||
}
|
||||
let help = get_help::<Opt>();
|
||||
let help = utils::get_help::<Opt>();
|
||||
assert!(help.contains("--arg <val>"));
|
||||
assert!(!help.contains("--arg <val>..."));
|
||||
}
|
|
@ -1,7 +1,8 @@
|
|||
mod utils;
|
||||
#![cfg(feature = "env")]
|
||||
|
||||
use crate::utils;
|
||||
|
||||
use clap::Parser;
|
||||
use utils::*;
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
|
@ -12,7 +13,7 @@ fn it_works() {
|
|||
be_nice: String,
|
||||
}
|
||||
|
||||
let help = get_help::<BehaviorModel>();
|
||||
let help = utils::get_help::<BehaviorModel>();
|
||||
assert!(help.contains("[env: be-nice=]"));
|
||||
}
|
||||
|
||||
|
@ -24,7 +25,7 @@ fn default_is_screaming() {
|
|||
be_nice: String,
|
||||
}
|
||||
|
||||
let help = get_help::<BehaviorModel>();
|
||||
let help = utils::get_help::<BehaviorModel>();
|
||||
assert!(help.contains("[env: BE_NICE=]"));
|
||||
}
|
||||
|
||||
|
@ -40,7 +41,7 @@ fn overridable() {
|
|||
be_aggressive: String,
|
||||
}
|
||||
|
||||
let help = get_help::<BehaviorModel>();
|
||||
let help = utils::get_help::<BehaviorModel>();
|
||||
assert!(help.contains("[env: be-nice=]"));
|
||||
assert!(help.contains("[env: BeAggressive=]"));
|
||||
}
|
|
@ -12,10 +12,9 @@
|
|||
// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the
|
||||
// MIT/Apache 2.0 license.
|
||||
|
||||
mod utils;
|
||||
use crate::utils;
|
||||
|
||||
use clap::{Args, Parser, Subcommand};
|
||||
use utils::*;
|
||||
|
||||
#[derive(Parser, PartialEq, Debug)]
|
||||
enum Opt {
|
||||
|
@ -157,7 +156,7 @@ fn test_tuple_commands() {
|
|||
Opt4::try_parse_from(&["test", "fetch", "origin"]).unwrap()
|
||||
);
|
||||
|
||||
let output = get_long_help::<Opt4>();
|
||||
let output = utils::get_long_help::<Opt4>();
|
||||
|
||||
assert!(output.contains("download history from remote"));
|
||||
assert!(output.contains("Add a file"));
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue