From 3df6bc8f1a2ecec1313bd9b36ff7283f840b8308 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Tue, 18 Jun 2024 14:38:48 +0200 Subject: add server and secret as arguments --- src/cli.rs | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 src/cli.rs (limited to 'src/cli.rs') 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 @@ +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, + + #[arg(short, long)] + pub secret: Option, +} + +#[derive(Subcommand)] +pub enum Commands { + Start { + /// id of the device + id: String, + #[arg(short, long)] + ping: Option, + }, + 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(gen: G, cmd: &mut clap::Command) { + generate(gen, cmd, cmd.get_name().to_string(), &mut std::io::stdout()); +} -- cgit v1.2.3