1use std::path::PathBuf;
13
14use clap::{Parser, ValueHint};
15use internet2::addr::ServiceAddr;
16use microservices::shell::shell_setup;
17use store_rpc::STORED_RPC_ENDPOINT;
18
19#[cfg(any(target_os = "linux"))]
20pub const STORED_DATA_DIR: &str = "~/.storm_node";
21#[cfg(any(target_os = "freebsd", target_os = "openbsd", target_os = "netbsd"))]
22pub const STORED_DATA_DIR: &str = "~/.storm_node";
23#[cfg(target_os = "macos")]
24pub const STORED_DATA_DIR: &str = "~/Library/Application Support/Storm Node";
25#[cfg(target_os = "windows")]
26pub const STORED_DATA_DIR: &str = "~\\AppData\\Local\\Storm Node";
27#[cfg(target_os = "ios")]
28pub const STORED_DATA_DIR: &str = "~/Documents";
29#[cfg(target_os = "android")]
30pub const STORED_DATA_DIR: &str = ".";
31
32pub const STORED_CONFIG: &str = "{data_dir}/stored.toml";
33
34#[derive(Parser)]
36#[derive(Clone, Ord, PartialOrd, Eq, PartialEq, Hash, Debug)]
37#[clap(author, version, name = "stored", about = "stored: storage microservice daemon")]
38pub struct Opts {
39 #[clap(short, long, global = true, parse(from_occurrences))]
43 pub verbose: u8,
44
45 #[clap(
50 short,
51 long,
52 global = true,
53 default_value = STORED_DATA_DIR,
54 env = "STORED_DATA_DIR",
55 value_hint = ValueHint::DirPath
56 )]
57 pub data_dir: PathBuf,
58
59 #[clap(
64 short = 'X',
65 long = "rpc",
66 global = true,
67 env = "STORED_RPC_ENDPOINT",
68 value_hint = ValueHint::FilePath,
69 default_value = STORED_RPC_ENDPOINT
70 )]
71 pub rpc_endpoint: ServiceAddr,
72
73 #[clap()]
75 pub tables: Vec<String>,
76}
77
78impl Opts {
79 pub fn process(&mut self) {
80 shell_setup(self.verbose, [&mut self.rpc_endpoint], &mut self.data_dir, &[]);
81 }
82}