mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 23:37:32 +00:00
parent
69d75949df
commit
f484e2da11
2 changed files with 45 additions and 1 deletions
|
@ -340,8 +340,8 @@ pub fn gen_augment(
|
||||||
let app_methods = parent_attribute.top_level_methods();
|
let app_methods = parent_attribute.top_level_methods();
|
||||||
let version = parent_attribute.version();
|
let version = parent_attribute.version();
|
||||||
quote! {{
|
quote! {{
|
||||||
let #app_var = #app_var#app_methods;
|
|
||||||
#( #args )*
|
#( #args )*
|
||||||
|
let #app_var = #app_var#app_methods;
|
||||||
#subcmd
|
#subcmd
|
||||||
#app_var#version
|
#app_var#version
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -12,7 +12,10 @@
|
||||||
// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the
|
// commit#ea76fa1b1b273e65e3b0b1046643715b49bec51f which is licensed under the
|
||||||
// MIT/Apache 2.0 license.
|
// MIT/Apache 2.0 license.
|
||||||
|
|
||||||
|
mod utils;
|
||||||
|
|
||||||
use clap::Clap;
|
use clap::Clap;
|
||||||
|
use utils::get_help;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn flatten() {
|
fn flatten() {
|
||||||
|
@ -168,3 +171,44 @@ fn flatten_with_doc_comment() {
|
||||||
opts: DaemonOpts,
|
opts: DaemonOpts,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn docstrings_ordering_with_multiple_clap() {
|
||||||
|
/// This is the docstring for Flattened
|
||||||
|
#[derive(Clap)]
|
||||||
|
struct Flattened {
|
||||||
|
#[clap(long)]
|
||||||
|
foo: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// This is the docstring for Command
|
||||||
|
#[derive(Clap)]
|
||||||
|
struct Command {
|
||||||
|
#[clap(flatten)]
|
||||||
|
flattened: Flattened,
|
||||||
|
}
|
||||||
|
|
||||||
|
let short_help = get_help::<Command>();
|
||||||
|
|
||||||
|
assert!(short_help.contains("This is the docstring for Command"));
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn docstrings_ordering_with_multiple_clap_partial() {
|
||||||
|
/// This is the docstring for Flattened
|
||||||
|
#[derive(Clap)]
|
||||||
|
struct Flattened {
|
||||||
|
#[clap(long)]
|
||||||
|
foo: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clap)]
|
||||||
|
struct Command {
|
||||||
|
#[clap(flatten)]
|
||||||
|
flattened: Flattened,
|
||||||
|
}
|
||||||
|
|
||||||
|
let short_help = get_help::<Command>();
|
||||||
|
|
||||||
|
assert!(short_help.contains("This is the docstring for Flattened"));
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue