1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use cote::prelude::*;
#[derive(Debug, Cote)]
#[cote(help)]
pub struct Cli {
#[allow(unused)]
debug: bool,
/// Query sub command
#[allow(unused)]
#[sub(foot = "Foot message of sub command query")]
#[sub(name = "q", head = "Head message of sub command query")]
query: Option<Query>,
}
#[derive(Debug, Cote)]
#[cote(help)]
pub struct Query {
#[allow(unused)]
#[arg(hint = "--row <usize>", help = "Set the row data of query")]
row: usize,
/// Set the format of query output
#[allow(unused)]
#[pos()]
format: String,
}
#[test]
fn help() {
assert!(help_impl().is_err());
}
fn help_impl() -> color_eyre::Result<()> {
color_eyre::install()?;
Cli::parse(Args::from(["app", "q", "--help"]))?;
// Output:
// Usage: cli q [-h,--help] <--row <usize>> [ARGS]
//
// Head message of sub command query
//
// Options:
// -h,--help Display help message
// --row <usize> Set the row data of query
//
// Args:
// format@1 Set the format of query output
//
// Foot message of sub command
Ok(())
}