From f206de5d49eda1900552a4b19f01c8c6985b7903 Mon Sep 17 00:00:00 2001 From: "Adam T. Carpenter" Date: Wed, 28 Apr 2021 19:58:27 -0400 Subject: finally committed to structopt arg parsing --- src/config.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/config.rs (limited to 'src/config.rs') diff --git a/src/config.rs b/src/config.rs new file mode 100644 index 0000000..4dd4433 --- /dev/null +++ b/src/config.rs @@ -0,0 +1,48 @@ +use std::{net::SocketAddrV4, path::PathBuf}; +use structopt::StructOpt; + +lazy_static! { + pub static ref INSTANCE: Config = Config::from_args(); +} + +#[derive(Debug, StructOpt)] +#[structopt(author, about)] +pub struct Config { + #[structopt( + name = "DIR", + required = true, + parse(from_str), + help = "The path to your data directory" + )] + pub data_dir: PathBuf, + + #[structopt( + name = "ADDR", + long = "bind-addr", + required = false, + default_value = "127.0.0.1:5353", + help = "Sets the IP address and port to bind to" + )] + pub bind_addr: SocketAddrV4, + + #[structopt( + long, + short, + multiple = true, + parse(from_occurrences), + help = "Increases log level" + )] + pub verbose: u8, + + #[structopt( + long, + help = "Creates a fresh data directory at DIR and exits; Fails if DIR exists" + )] + pub create_dir: bool, + + #[structopt(long, help = "Imports CSV car data into the data directory")] + pub import_cars: bool, + + #[structopt(long, help = "Imports CSV parts data into the data directory")] + pub import_parts: bool, +} -- cgit v1.2.3