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
|
use clap::{arg, command, Parser, Subcommand};
use clap_complete::{generate, Generator, Shell};
/// webol client
#[derive(Parser)]
#[command(author, version, about, long_about = None)]
pub struct Args {
#[command(subcommand)]
pub commands: Commands,
#[arg(long)]
pub server: Option<String>,
#[arg(short, long)]
pub secret: Option<String>,
}
#[derive(Subcommand)]
pub enum Commands {
Start {
/// id of the device
id: String,
#[arg(short, long)]
ping: Option<bool>,
},
Device {
#[command(subcommand)]
devicecmd: DeviceCmd,
},
CliGen {
id: Shell,
},
}
#[derive(Subcommand)]
pub enum DeviceCmd {
Add {
id: String,
mac: String,
broadcast_addr: String,
ip: String,
},
Get {
id: String,
},
Edit {
id: String,
mac: String,
broadcast_addr: String,
ip: String,
},
}
pub fn print_completions<G: Generator>(gen: G, cmd: &mut clap::Command) {
generate(gen, cmd, cmd.get_name().to_string(), &mut std::io::stdout());
}
|