over_there/cli/opts/
mod.rs1pub mod client;
2mod parsers;
3pub mod schema;
4pub mod server;
5pub mod types;
6
7use clap::Clap;
8use std::time::Duration;
9use strum::VariantNames;
10
11#[derive(Clap, Debug)]
12pub enum Command {
13 #[clap(name = "client")]
15 Client(client::ClientCommand),
16
17 #[clap(name = "server")]
19 Server(server::ServerCommand),
20
21 #[clap(name = "schema")]
23 Schema(schema::SchemaCommand),
24}
25
26impl Command {
27 pub fn common_opts(&self) -> Option<&CommonOpts> {
28 match self {
29 Self::Client(c) => Some(&c.opts),
30 Self::Server(s) => Some(&s.opts),
31 Self::Schema(_) => None,
32 }
33 }
34}
35
36#[derive(Clap, Debug)]
37#[clap(author, about, version)]
38pub struct Opts {
39 #[clap(subcommand)]
40 pub command: Command,
41}
42
43#[derive(Clap, Debug)]
44pub struct CommonOpts {
45 #[clap(long, parse(try_from_str = parsers::parse_duration_secs), default_value = "5")]
47 pub timeout: Duration,
48
49 #[clap(long, parse(try_from_str = parsers::parse_duration_secs), default_value = "300")]
51 pub packet_ttl: Duration,
52
53 #[clap(long, default_value = "1000")]
56 pub internal_buffer_size: usize,
57
58 #[clap(
60 short = "t",
61 long,
62 parse(try_from_str),
63 possible_values = &types::Transport::VARIANTS,
64 default_value = types::Transport::Udp.as_ref(),
65 )]
66 pub transport: types::Transport,
67
68 #[clap(
70 short = "e",
71 long,
72 parse(try_from_str),
73 possible_values = &types::Encryption::VARIANTS,
74 default_value = types::Encryption::None.as_ref(),
75 )]
76 pub encryption: types::Encryption,
77
78 #[clap(long = "ekey")]
80 pub encryption_key: Option<String>,
81
82 #[clap(
84 short = "a",
85 long,
86 parse(try_from_str),
87 possible_values = &types::Authentication::VARIANTS,
88 default_value = types::Authentication::None.as_ref(),
89 )]
90 pub authentication: types::Authentication,
91
92 #[clap(long = "akey")]
94 pub authentication_key: Option<String>,
95}