toe_beans/v4/client/
config.rs1use std::net::{Ipv4Addr, SocketAddrV4};
2
3use clap::{Parser, Subcommand};
4
5use super::RESOLVED_CLIENT_PORT;
6
7#[derive(Parser, Debug)]
9#[command(version)]
10pub struct Arguments {
11 #[command(subcommand)]
13 pub command: Commands,
14 #[command(flatten)]
16 pub client_config: Option<ClientConfig>,
17}
18
19#[derive(Parser, Debug)]
21pub struct ClientConfig {
22 #[arg(long)]
24 pub interface: Option<String>,
25 #[arg(long)]
27 pub listen_address: Option<SocketAddrV4>,
28}
29
30impl Default for ClientConfig {
31 fn default() -> Self {
32 Self {
33 interface: None,
34 listen_address: Some(SocketAddrV4::new(
35 Ipv4Addr::new(0, 0, 0, 0),
36 RESOLVED_CLIENT_PORT,
37 )),
38 }
39 }
40}
41
42impl ClientConfig {
43 pub fn merge(self, other: Self) -> Self {
46 Self {
47 interface: self.interface.or(other.interface),
48 listen_address: self.listen_address.or(other.listen_address),
49 }
50 }
51}
52
53#[derive(Subcommand, Debug)]
56pub enum Commands {
57 Dora {},
59 Release {},
61 Inform {},
63 Decline {},
65}