seaplane_cli/cli/cmds/locks/
common.rs1use clap::{value_parser, Arg, ArgMatches};
2
3const LONG_DECODE: &str = "Decode the lock name before printing it
4
5Binary values will be written directly to standard output (which may do strange
6things to your terminal)";
7
8#[allow(missing_debug_implementations)]
12pub struct SeaplaneLocksCommonArgMatches<'a>(pub &'a ArgMatches);
13
14pub fn display_args() -> Vec<Arg> {
15 vec![
16 arg!(--decode - ('D'))
17 .help("Decode the lockname before printing it (WARNING! See --help)")
18 .long_help(LONG_DECODE)
19 .overrides_with("no-decode"),
20 arg!(--("no-decode"))
21 .help("Print lockname without decoding it")
22 .overrides_with("decode"),
23 arg!(--("no-header") | ("no-heading") | ("no-headers"))
24 .help("Omit the heading when printing with `--format=table`"),
25 ]
26}
27
28pub fn base64() -> Arg {
29 arg!(--base64 - ('B')).help("The lockname is already encoded in URL safe Base64")
30}
31
32pub fn ttl() -> Arg {
33 arg!(--ttl - ('T') =["SECS"] required)
34 .value_parser(value_parser!(u32))
35 .help("The TTL (Time To Live) in seconds, i.e. a positive integer")
36}
37
38pub fn lock_id() -> Arg {
39 arg!(--("lock-id") - ('L') =["STRING"] required).help(
40 "A valid lock-id can be obtained from a successful acquisition, or listing of the locks",
41 )
42}
43
44pub fn lock_name() -> Arg { arg!(lock_name =["LOCK_NAME"] required ).help("The name of the lock") }