summaryrefslogblamecommitdiff
path: root/src/config.rs
blob: 4dd4433cb6dadfafeb7cad7e76a2d7c2ef73ba56 (plain) (tree)















































                                                                                     
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,
}