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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use clap::{Arg, ArgGroup, ArgMatches};
const LONG_DECODE: &str = "Decode the keys and values before printing them
Binary values will be written directly to standard output (which may do strange
things to your terminal)";
const LONG_HUMAN_READABLE: &str = "Safely decode and truncate output for human readability
Implies --decode-safe --values-width-limit 256";
#[allow(missing_debug_implementations)]
#[derive(Debug)]
pub struct SeaplaneMetadataCommonArgMatches<'a>(pub &'a ArgMatches);
pub fn args() -> Vec<Arg<'static>> { vec![keys(), base64()] }
pub fn display_args() -> Vec<Arg<'static>> {
vec![
arg!(--("human-readable") - ('H'))
.help("Safely decode and truncate output for human readability")
.long_help(LONG_HUMAN_READABLE),
arg!(--decode - ('D'))
.help("Decode the keys and values before printing them")
.long_help(LONG_DECODE)
.overrides_with_all(&["no-decode", "decode-safe"]),
arg!(--("decode-safe"))
.help("Decode the keys and values in a terminal-friendly way")
.overrides_with_all(&["decode", "no-decode"]),
arg!(--("no-decode"))
.help("Print keys and values without decoding them")
.overrides_with_all(&["decode", "decode-safe"]),
arg!(--("no-header") | ("no-heading") | ("no-headers"))
.help("Omit the 'KEY' or 'VALUE' heading when printing with `--format=table`"),
arg!(--("only-values") | ("only-value")).help("Only print the value"),
arg!(--("only-keys") | ("only-key")).help("Only print the key"),
arg!(--("keys-width-limit") = ["LIMIT"])
.help("Limit the width of the keys when using `--format=table` (0 means unlimited)")
.takes_value(true)
.value_parser(clap::value_parser!(usize)),
arg!(--("values-width-limit") = ["LIMIT"])
.default_value_if("human-readable", None, Some("256"))
.help("Limit the width of the values when using `--format=table` (0 means unlimited)")
.takes_value(true)
.value_parser(clap::value_parser!(usize)),
]
}
pub fn base64() -> Arg<'static> {
arg!(--base64 - ('B')).help("The keys/values are already encoded in URL safe Base64")
}
pub fn single_key() -> Arg<'static> {
arg!(key =["KEY"] required ).help("The key of the metadata key-value pair")
}
pub fn keys() -> Arg<'static> {
arg!(key =["KEY"]... required ).help("The key(s) of the metadata key-value pair")
}
pub fn keys_or_values() -> ArgGroup<'static> {
ArgGroup::new("keys_or_values")
.args(&["only-keys", "only-values"])
.multiple(false)
.required(false)
}