diff options
author | fxqnlr <[email protected]> | 2024-06-18 14:38:48 +0200 |
---|---|---|
committer | fxqnlr <[email protected]> | 2024-06-18 14:38:48 +0200 |
commit | 3df6bc8f1a2ecec1313bd9b36ff7283f840b8308 (patch) | |
tree | f780cf73a1a41de6a9314c6e5a6d1fa07fb8c37a /src/cli.rs | |
parent | b375657e660b199127a76683980a5d210a572ab7 (diff) | |
download | webol-cli-3df6bc8f1a2ecec1313bd9b36ff7283f840b8308.tar webol-cli-3df6bc8f1a2ecec1313bd9b36ff7283f840b8308.tar.gz webol-cli-3df6bc8f1a2ecec1313bd9b36ff7283f840b8308.zip |
add server and secret as argumentsargs
Diffstat (limited to 'src/cli.rs')
-rw-r--r-- | src/cli.rs | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/cli.rs b/src/cli.rs new file mode 100644 index 0000000..9119338 --- /dev/null +++ b/src/cli.rs | |||
@@ -0,0 +1,56 @@ | |||
1 | use clap::{arg, command, Parser, Subcommand}; | ||
2 | use clap_complete::{generate, Generator, Shell}; | ||
3 | |||
4 | /// webol client | ||
5 | #[derive(Parser)] | ||
6 | #[command(author, version, about, long_about = None)] | ||
7 | pub struct Args { | ||
8 | #[command(subcommand)] | ||
9 | pub commands: Commands, | ||
10 | |||
11 | #[arg(long)] | ||
12 | pub server: Option<String>, | ||
13 | |||
14 | #[arg(short, long)] | ||
15 | pub secret: Option<String>, | ||
16 | } | ||
17 | |||
18 | #[derive(Subcommand)] | ||
19 | pub enum Commands { | ||
20 | Start { | ||
21 | /// id of the device | ||
22 | id: String, | ||
23 | #[arg(short, long)] | ||
24 | ping: Option<bool>, | ||
25 | }, | ||
26 | Device { | ||
27 | #[command(subcommand)] | ||
28 | devicecmd: DeviceCmd, | ||
29 | }, | ||
30 | CliGen { | ||
31 | id: Shell, | ||
32 | }, | ||
33 | } | ||
34 | |||
35 | #[derive(Subcommand)] | ||
36 | pub enum DeviceCmd { | ||
37 | Add { | ||
38 | id: String, | ||
39 | mac: String, | ||
40 | broadcast_addr: String, | ||
41 | ip: String, | ||
42 | }, | ||
43 | Get { | ||
44 | id: String, | ||
45 | }, | ||
46 | Edit { | ||
47 | id: String, | ||
48 | mac: String, | ||
49 | broadcast_addr: String, | ||
50 | ip: String, | ||
51 | }, | ||
52 | } | ||
53 | |||
54 | pub fn print_completions<G: Generator>(gen: G, cmd: &mut clap::Command) { | ||
55 | generate(gen, cmd, cmd.get_name().to_string(), &mut std::io::stdout()); | ||
56 | } | ||