hashiverse_server_lib/server/
args.rs1use clap::Parser;
11
12#[derive(Parser, Debug, Clone)]
13#[command(version, about, long_about = None)]
14pub struct Args {
15 #[arg(long, default_value_t = 443)]
17 pub port: u16,
18
19 #[arg(long, default_value_t = false)]
21 pub force_local_network: bool,
22
23 #[arg(long, default_value = "./.hashiverse")]
25 pub base_path: String,
26
27 #[arg(long, default_value_t = 20*1024)]
29 pub max_post_database_size_megabytes: usize,
30
31 #[arg(long)]
33 pub passphrase_path: Option<String>,
34
35 #[arg(long, default_value = "trace")]
37 pub log_level: String,
38
39 #[arg(long, default_value = "false")]
41 pub skip_pq_commitment_bytes: bool
42}
43
44impl Args {
45 pub fn new() -> Self {
46 Args::parse()
47 }
48
49 pub fn default_for_testing() -> Self {
50 let selfie = Self::parse_from([""]);
51 selfie.with_skip_pq_commitment_bytes(true).with_force_local_network(true)
52 }
53
54
55 pub fn with_port(mut self, port: u16) -> Self {
56 self.port = port;
57 self
58 }
59
60 pub fn with_force_local_network(mut self, v: bool) -> Self {
61 self.force_local_network = v;
62 self
63 }
64
65 pub fn with_base_path(mut self, base_path: String) -> Self {
66 self.base_path = base_path;
67 self
68 }
69
70 pub fn with_max_post_database_size_megabytes(mut self, max_post_database_size_megabytes: usize) -> Self {
71 self.max_post_database_size_megabytes = max_post_database_size_megabytes;
72 self
73 }
74
75 pub fn with_skip_pq_commitment_bytes(mut self, skip_pq_commitment_bytes: bool) -> Self {
76 self.skip_pq_commitment_bytes = skip_pq_commitment_bytes;
77 self
78 }
79}
80
81impl Default for Args {
82 fn default() -> Self {
83 Self::parse_from([""])
84 }
85}