Update bench tests with about and add inline to about methods

This commit is contained in:
creativcoder 2020-04-27 20:00:36 +05:30
parent 266dbbe3f4
commit 35fdb45adb
5 changed files with 36 additions and 34 deletions

View file

@ -54,7 +54,7 @@ pub fn build_from_builder(c: &mut Criterion) {
.author("Kevin K. <kbknapp@gmail.com>")
.arg(
Arg::with_name("opt")
.help("tests options")
.about("tests options")
.short('o')
.long("option")
.setting(ArgSettings::MultipleValues)
@ -62,13 +62,13 @@ pub fn build_from_builder(c: &mut Criterion) {
)
.arg(
Arg::with_name("positional")
.help("tests positionals")
.about("tests positionals")
.index(1),
)
.arg(
Arg::with_name("flag")
.short('f')
.help("tests flags")
.about("tests flags")
.long("flag")
.global(true)
.settings(&[ArgSettings::MultipleOccurrences]),
@ -76,13 +76,13 @@ pub fn build_from_builder(c: &mut Criterion) {
.arg(
Arg::with_name("flag2")
.short('F')
.help("tests flags with exclusions")
.about("tests flags with exclusions")
.conflicts_with("flag")
.requires("option2"),
)
.arg(
Arg::with_name("option2")
.help("tests long options with exclusions")
.about("tests long options with exclusions")
.conflicts_with("option")
.requires("positional2")
.setting(ArgSettings::TakesValue)
@ -91,28 +91,28 @@ pub fn build_from_builder(c: &mut Criterion) {
.arg(
Arg::with_name("positional2")
.index(3)
.help("tests positionals with exclusions"),
.about("tests positionals with exclusions"),
)
.arg(
Arg::with_name("option3")
.short('O')
.long("Option")
.setting(ArgSettings::TakesValue)
.help("tests options with specific value sets")
.about("tests options with specific value sets")
.possible_values(&OPT3_VALS),
)
.arg(
Arg::with_name("positional3")
.setting(ArgSettings::MultipleValues)
.setting(ArgSettings::MultipleOccurrences)
.help("tests positionals with specific values")
.about("tests positionals with specific values")
.index(4)
.possible_values(&POS3_VALS),
)
.arg(
Arg::with_name("multvals")
.long("multvals")
.help("Tests mutliple values, not mult occs")
.about("Tests mutliple values, not mult occs")
.value_names(&["one", "two"]),
)
.arg(
@ -120,7 +120,7 @@ pub fn build_from_builder(c: &mut Criterion) {
.long("multvalsmo")
.setting(ArgSettings::MultipleValues)
.setting(ArgSettings::MultipleOccurrences)
.help("Tests mutliple values, not mult occs")
.about("Tests mutliple values, not mult occs")
.value_names(&["one", "two"]),
)
.arg(
@ -128,7 +128,7 @@ pub fn build_from_builder(c: &mut Criterion) {
.long("minvals2")
.setting(ArgSettings::MultipleValues)
.setting(ArgSettings::MultipleOccurrences)
.help("Tests 2 min vals")
.about("Tests 2 min vals")
.min_values(2),
)
.arg(
@ -136,7 +136,7 @@ pub fn build_from_builder(c: &mut Criterion) {
.long("maxvals3")
.setting(ArgSettings::MultipleValues)
.setting(ArgSettings::MultipleOccurrences)
.help("Tests 3 max vals")
.about("Tests 3 max vals")
.max_values(3),
)
.subcommand(
@ -150,12 +150,12 @@ pub fn build_from_builder(c: &mut Criterion) {
.long("option")
.setting(ArgSettings::MultipleValues)
.setting(ArgSettings::MultipleOccurrences)
.help("tests options"),
.about("tests options"),
)
.arg(
Arg::with_name("scpositional")
.index(1)
.help("tests positionals"),
.about("tests positionals"),
),
)
})

View file

@ -36,17 +36,17 @@ fn app_example3<'c>() -> App<'c> {
App::new("MyApp")
.arg(
Arg::with_name("debug")
.help("turn on debugging information")
.about("turn on debugging information")
.short('d'),
)
.args(&[
Arg::with_name("config")
.help("sets the config file to use")
.about("sets the config file to use")
.setting(ArgSettings::TakesValue)
.short('c')
.long("config"),
Arg::with_name("input")
.help("the input file to use")
.about("the input file to use")
.index(1)
.setting(ArgSettings::Required),
])
@ -62,19 +62,19 @@ fn app_example4<'c>() -> App<'c> {
.author("Kevin K. <kbknapp@gmail.com>")
.arg(
Arg::with_name("debug")
.help("turn on debugging information")
.about("turn on debugging information")
.short('d')
.long("debug"),
)
.arg(
Arg::with_name("config")
.help("sets the config file to use")
.about("sets the config file to use")
.short('c')
.long("config"),
)
.arg(
Arg::with_name("input")
.help("the input file to use")
.about("the input file to use")
.index(1)
.setting(ArgSettings::Required),
)
@ -83,7 +83,7 @@ fn app_example4<'c>() -> App<'c> {
fn app_example5<'c>() -> App<'c> {
App::new("MyApp").arg(
Arg::with_name("awesome")
.help("turns up the awesome")
.about("turns up the awesome")
.short('a')
.long("awesome")
.setting(ArgSettings::MultipleOccurrences)
@ -96,7 +96,7 @@ fn app_example6<'c>() -> App<'c> {
App::new("MyApp")
.arg(
Arg::with_name("input")
.help("the input file to use")
.about("the input file to use")
.index(1)
.requires("config")
.conflicts_with("output")
@ -104,7 +104,7 @@ fn app_example6<'c>() -> App<'c> {
)
.arg(
Arg::with_name("config")
.help("the config file to use")
.about("the config file to use")
.index(2),
)
}
@ -115,7 +115,7 @@ fn app_example7<'c>() -> App<'c> {
.arg(Arg::with_name("output"))
.arg(
Arg::with_name("input")
.help("the input file to use")
.about("the input file to use")
.settings(&[
ArgSettings::MultipleValues,
ArgSettings::MultipleOccurrences,
@ -134,7 +134,7 @@ fn app_example8<'c>() -> App<'c> {
.arg(Arg::with_name("output"))
.arg(
Arg::with_name("input")
.help("the input file to use")
.about("the input file to use")
.settings(&[
ArgSettings::MultipleValues,
ArgSettings::MultipleOccurrences,
@ -150,7 +150,7 @@ fn app_example8<'c>() -> App<'c> {
fn app_example10<'c>() -> App<'c> {
App::new("myapp").about("does awesome things").arg(
Arg::with_name("CONFIG")
.help("The config file to use (default is \"config.json\")")
.about("The config file to use (default is \"config.json\")")
.short('c')
.setting(ArgSettings::TakesValue),
)

View file

@ -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::with_name(name).help(doc(name));
let arg = |name| Arg::with_name(name).about(doc(name));
let flag = |name| arg(name).long(name);
App::new("ripgrep")

View file

@ -31,7 +31,7 @@ fn build_cli() -> App<'static> {
// .setting(AppSettings::SubcommandRequiredElseHelp)
.arg(
Arg::with_name("verbose")
.help("Enable verbose output")
.about("Enable verbose output")
.short('v')
.long("verbose"),
)
@ -54,7 +54,7 @@ fn build_cli() -> App<'static> {
.arg(Arg::with_name("toolchain").setting(ArgSettings::Required))
.arg(
Arg::with_name("no-self-update")
.help("Don't perform self update when running the `rustup` command")
.about("Don't perform self update when running the `rustup` command")
.long("no-self-update")
.setting(ArgSettings::Hidden),
),
@ -227,12 +227,12 @@ fn build_cli() -> App<'static> {
Arg::with_name("path")
.long("path")
.setting(ArgSettings::TakesValue)
.help("Path to the directory"),
.about("Path to the directory"),
)
.arg(
Arg::with_name("nonexistent")
.long("nonexistent")
.help("Remove override toolchain for all nonexistent directories"),
.about("Remove override toolchain for all nonexistent directories"),
),
)
.subcommand(
@ -252,7 +252,7 @@ fn build_cli() -> App<'static> {
.arg(
Arg::with_name("nonexistent")
.long("nonexistent")
.help("Remove override toolchain for all nonexistent directories"),
.about("Remove override toolchain for all nonexistent directories"),
),
),
)
@ -280,12 +280,12 @@ fn build_cli() -> App<'static> {
.arg(
Arg::with_name("book")
.long("book")
.help("The Rust Programming Language book"),
.about("The Rust Programming Language book"),
)
.arg(
Arg::with_name("std")
.long("std")
.help("Standard library API documentation"),
.about("Standard library API documentation"),
)
.group(ArgGroup::with_name("page").args(&["book", "std"])),
)

View file

@ -632,6 +632,7 @@ impl<'help> Arg<'help> {
/// -V, --version Prints version information
/// ```
/// [`Arg::long_about`]: ./struct.Arg.html#method.long_about
#[inline]
pub fn about(mut self, h: &'help str) -> Self {
self.about = Some(h);
self
@ -703,6 +704,7 @@ impl<'help> Arg<'help> {
/// Prints version information
///
/// [`Arg::about`]: ./struct.Arg.html#method.about
#[inline]
pub fn long_about(mut self, h: &'help str) -> Self {
self.long_about = Some(h);
self