Skip to content
This repository has been archived by the owner on Jan 1, 2022. It is now read-only.

Commit

Permalink
Merge pull request #17 from epage/revert
Browse files Browse the repository at this point in the history
Revert "Deprecate Arg::help in favour of Arg::about"
  • Loading branch information
epage authored Nov 18, 2021
2 parents 154a88d + 7e899cd commit 700efb1
Show file tree
Hide file tree
Showing 69 changed files with 590 additions and 600 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,24 +222,24 @@ fn main() {
.short('c')
.long("config")
.value_name("FILE")
.about("Sets a custom config file")
.help("Sets a custom config file")
.takes_value(true))
.arg(Arg::new("INPUT")
.about("Sets the input file to use")
.help("Sets the input file to use")
.required(true)
.index(1))
.arg(Arg::new("v")
.short('v')
.multiple_occurrences(true)
.takes_value(true)
.about("Sets the level of verbosity"))
.help("Sets the level of verbosity"))
.subcommand(App::new("test")
.about("controls testing features")
.version("1.3")
.author("Someone E. <[email protected]>")
.arg(Arg::new("debug")
.short('d')
.about("print debug information verbosely")))
.help("print debug information verbosely")))
.get_matches();
// You can check the value provided by positional arguments, or option arguments
Expand Down Expand Up @@ -321,16 +321,16 @@ args:
short: c
long: config
value_name: FILE
about: Sets a custom config file
help: Sets a custom config file
takes_value: true
- INPUT:
about: Sets the input file to use
help: Sets the input file to use
required: true
index: 1
- verbose:
short: v
multiple_occurrences: true
about: Sets the level of verbosity
help: Sets the level of verbosity
subcommands:
- test:
about: controls testing features
Expand All @@ -340,7 +340,7 @@ subcommands:
- debug:
short: d
long: debug
about: Print debug information
help: Print debug information
```
Since this feature requires additional dependencies that not everyone may want, it is *not* compiled in by default and we need to enable a feature flag in Cargo.toml:
Expand Down
28 changes: 14 additions & 14 deletions benches/03_complex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,32 +54,32 @@ pub fn build_from_builder(c: &mut Criterion) {
.author("Kevin K. <[email protected]>")
.arg(
Arg::new("opt")
.about("tests options")
.help("tests options")
.short('o')
.long("option")
.setting(ArgSettings::TakesValue)
.setting(ArgSettings::MultipleValues)
.setting(ArgSettings::MultipleOccurrences),
)
.arg(Arg::new("positional").about("tests positionals").index(1))
.arg(Arg::new("positional").help("tests positionals").index(1))
.arg(
Arg::new("flag")
.short('f')
.about("tests flags")
.help("tests flags")
.long("flag")
.global(true)
.setting(ArgSettings::MultipleOccurrences),
)
.arg(
Arg::new("flag2")
.short('F')
.about("tests flags with exclusions")
.help("tests flags with exclusions")
.conflicts_with("flag")
.requires("option2"),
)
.arg(
Arg::new("option2")
.about("tests long options with exclusions")
.help("tests long options with exclusions")
.conflicts_with("option")
.requires("positional2")
.setting(ArgSettings::TakesValue)
Expand All @@ -88,29 +88,29 @@ pub fn build_from_builder(c: &mut Criterion) {
.arg(
Arg::new("positional2")
.index(3)
.about("tests positionals with exclusions"),
.help("tests positionals with exclusions"),
)
.arg(
Arg::new("option3")
.short('O')
.long("Option")
.setting(ArgSettings::TakesValue)
.about("tests options with specific value sets")
.help("tests options with specific value sets")
.possible_values(OPT3_VALS),
)
.arg(
Arg::new("positional3")
.setting(ArgSettings::TakesValue)
.setting(ArgSettings::MultipleValues)
.setting(ArgSettings::MultipleOccurrences)
.about("tests positionals with specific values")
.help("tests positionals with specific values")
.index(4)
.possible_values(POS3_VALS),
)
.arg(
Arg::new("multvals")
.long("multvals")
.about("Tests multiple values, not mult occs")
.help("Tests multiple values, not mult occs")
.value_names(&["one", "two"]),
)
.arg(
Expand All @@ -119,7 +119,7 @@ pub fn build_from_builder(c: &mut Criterion) {
.setting(ArgSettings::TakesValue)
.setting(ArgSettings::MultipleValues)
.setting(ArgSettings::MultipleOccurrences)
.about("Tests multiple values, not mult occs")
.help("Tests multiple values, not mult occs")
.value_names(&["one", "two"]),
)
.arg(
Expand All @@ -128,7 +128,7 @@ pub fn build_from_builder(c: &mut Criterion) {
.setting(ArgSettings::TakesValue)
.setting(ArgSettings::MultipleValues)
.setting(ArgSettings::MultipleOccurrences)
.about("Tests 2 min vals")
.help("Tests 2 min vals")
.min_values(2),
)
.arg(
Expand All @@ -137,7 +137,7 @@ pub fn build_from_builder(c: &mut Criterion) {
.setting(ArgSettings::TakesValue)
.setting(ArgSettings::MultipleValues)
.setting(ArgSettings::MultipleOccurrences)
.about("Tests 3 max vals")
.help("Tests 3 max vals")
.max_values(3),
)
.subcommand(
Expand All @@ -152,9 +152,9 @@ pub fn build_from_builder(c: &mut Criterion) {
.setting(ArgSettings::TakesValue)
.setting(ArgSettings::MultipleValues)
.setting(ArgSettings::MultipleOccurrences)
.about("tests options"),
.help("tests options"),
)
.arg(Arg::new("scpositional").index(1).about("tests positionals")),
.arg(Arg::new("scpositional").index(1).help("tests positionals")),
)
})
});
Expand Down
24 changes: 12 additions & 12 deletions benches/04_new_help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,17 @@ fn app_example3<'c>() -> App<'c> {
App::new("MyApp")
.arg(
Arg::new("debug")
.about("turn on debugging information")
.help("turn on debugging information")
.short('d'),
)
.args(&[
Arg::new("config")
.about("sets the config file to use")
.help("sets the config file to use")
.setting(ArgSettings::TakesValue)
.short('c')
.long("config"),
Arg::new("input")
.about("the input file to use")
.help("the input file to use")
.index(1)
.setting(ArgSettings::Required),
])
Expand All @@ -62,19 +62,19 @@ fn app_example4<'c>() -> App<'c> {
.author("Kevin K. <[email protected]>")
.arg(
Arg::new("debug")
.about("turn on debugging information")
.help("turn on debugging information")
.short('d')
.long("debug"),
)
.arg(
Arg::new("config")
.about("sets the config file to use")
.help("sets the config file to use")
.short('c')
.long("config"),
)
.arg(
Arg::new("input")
.about("the input file to use")
.help("the input file to use")
.index(1)
.setting(ArgSettings::Required),
)
Expand All @@ -83,7 +83,7 @@ fn app_example4<'c>() -> App<'c> {
fn app_example5<'c>() -> App<'c> {
App::new("MyApp").arg(
Arg::new("awesome")
.about("turns up the awesome")
.help("turns up the awesome")
.short('a')
.long("awesome")
.setting(ArgSettings::MultipleOccurrences)
Expand All @@ -96,13 +96,13 @@ fn app_example6<'c>() -> App<'c> {
App::new("MyApp")
.arg(
Arg::new("input")
.about("the input file to use")
.help("the input file to use")
.index(1)
.requires("config")
.conflicts_with("output")
.setting(ArgSettings::Required),
)
.arg(Arg::new("config").about("the config file to use").index(2))
.arg(Arg::new("config").help("the config file to use").index(2))
}

fn app_example7<'c>() -> App<'c> {
Expand All @@ -111,7 +111,7 @@ fn app_example7<'c>() -> App<'c> {
.arg(Arg::new("output"))
.arg(
Arg::new("input")
.about("the input file to use")
.help("the input file to use")
.setting(ArgSettings::TakesValue)
.setting(ArgSettings::MultipleValues)
.setting(ArgSettings::MultipleOccurrences)
Expand All @@ -129,7 +129,7 @@ fn app_example8<'c>() -> App<'c> {
.arg(Arg::new("output"))
.arg(
Arg::new("input")
.about("the input file to use")
.help("the input file to use")
.setting(ArgSettings::TakesValue)
.setting(ArgSettings::MultipleValues)
.setting(ArgSettings::MultipleOccurrences)
Expand All @@ -144,7 +144,7 @@ fn app_example8<'c>() -> App<'c> {
fn app_example10<'c>() -> App<'c> {
App::new("myapp").about("does awesome things").arg(
Arg::new("CONFIG")
.about("The config file to use (default is \"config.json\")")
.help("The config file to use (default is \"config.json\")")
.short('c')
.setting(ArgSettings::TakesValue),
)
Expand Down
2 changes: 1 addition & 1 deletion benches/05_ripgrep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ fn app<F>(_next_line_help: bool, doc: F) -> App<'static>
where
F: Fn(&'static str) -> &'static str,
{
let arg = |name| Arg::new(name).about(doc(name));
let arg = |name| Arg::new(name).help(doc(name));
let flag = |name| arg(name).long(name);

App::new("ripgrep")
Expand Down
14 changes: 7 additions & 7 deletions benches/06_rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn build_cli() -> App<'static> {
// .setting(AppSettings::SubcommandRequiredElseHelp)
.arg(
Arg::new("verbose")
.about("Enable verbose output")
.help("Enable verbose output")
.short('v')
.long("verbose"),
)
Expand All @@ -53,7 +53,7 @@ fn build_cli() -> App<'static> {
.arg(Arg::new("toolchain").setting(ArgSettings::Required))
.arg(
Arg::new("no-self-update")
.about("Don't perform self update when running the `rustup` command")
.help("Don't perform self update when running the `rustup` command")
.long("no-self-update")
.setting(ArgSettings::Hidden),
),
Expand Down Expand Up @@ -223,12 +223,12 @@ fn build_cli() -> App<'static> {
Arg::new("path")
.long("path")
.setting(ArgSettings::TakesValue)
.about("Path to the directory"),
.help("Path to the directory"),
)
.arg(
Arg::new("nonexistent")
.long("nonexistent")
.about("Remove override toolchain for all nonexistent directories"),
.help("Remove override toolchain for all nonexistent directories"),
),
)
.subcommand(
Expand All @@ -248,7 +248,7 @@ fn build_cli() -> App<'static> {
.arg(
Arg::new("nonexistent")
.long("nonexistent")
.about("Remove override toolchain for all nonexistent directories"),
.help("Remove override toolchain for all nonexistent directories"),
),
),
)
Expand Down Expand Up @@ -278,12 +278,12 @@ fn build_cli() -> App<'static> {
.arg(
Arg::new("book")
.long("book")
.about("The Rust Programming Language book"),
.help("The Rust Programming Language book"),
)
.arg(
Arg::new("std")
.long("std")
.about("Standard library API documentation"),
.help("Standard library API documentation"),
)
.group(ArgGroup::new("page").args(&["book", "std"])),
)
Expand Down
2 changes: 1 addition & 1 deletion clap_derive/examples/doc_comments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct Opt {
#[clap(
short,
long,
long_about = r"This is a raw string.
long_help = r"This is a raw string.
It can be used to pass well formatted content (e.g. lists or source
code) in the description:
Expand Down
12 changes: 6 additions & 6 deletions clap_derive/src/attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ impl Attrs {
env_casing,
);
res.push_attrs(&variant.attrs);
res.push_doc_comment(&variant.attrs, "about");
res.push_doc_comment(&variant.attrs, "help");

if res.has_custom_parser {
abort!(
Expand Down Expand Up @@ -626,7 +626,7 @@ impl Attrs {
env_casing,
);
res.push_attrs(&field.attrs);
res.push_doc_comment(&field.attrs, "about");
res.push_doc_comment(&field.attrs, "help");

match &*res.kind {
Kind::Flatten => {
Expand Down Expand Up @@ -794,10 +794,10 @@ impl Attrs {
}

/// generate methods on top of a field
pub fn field_methods(&self, supports_long_about: bool) -> proc_macro2::TokenStream {
pub fn field_methods(&self, supports_long_help: bool) -> proc_macro2::TokenStream {
let methods = &self.methods;
let help_heading = self.help_heading.as_ref().into_iter();
match supports_long_about {
match supports_long_help {
true => {
let doc_comment = &self.doc_comment;
quote!( #(#doc_comment)* #(#help_heading)* #(#methods)* )
Expand All @@ -806,7 +806,7 @@ impl Attrs {
let doc_comment = self
.doc_comment
.iter()
.filter(|mth| mth.name != "long_about");
.filter(|mth| mth.name != "long_help");
quote!( #(#doc_comment)* #(#help_heading)* #(#methods)* )
}
}
Expand Down Expand Up @@ -864,7 +864,7 @@ impl Attrs {
pub fn has_explicit_methods(&self) -> bool {
self.methods
.iter()
.any(|m| m.name != "about" && m.name != "long_about")
.any(|m| m.name != "help" && m.name != "long_help")
}
}

Expand Down
Loading

0 comments on commit 700efb1

Please sign in to comment.