|
|
@ -9,6 +9,8 @@ use log::LevelFilter;
|
|
|
|
pub struct Config {
|
|
|
|
pub struct Config {
|
|
|
|
pub config_directory: PathBuf,
|
|
|
|
pub config_directory: PathBuf,
|
|
|
|
pub log_level: LevelFilter,
|
|
|
|
pub log_level: LevelFilter,
|
|
|
|
|
|
|
|
pub stdout: PathBuf,
|
|
|
|
|
|
|
|
pub stderr: PathBuf,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Config {
|
|
|
|
impl Config {
|
|
|
@ -24,6 +26,8 @@ impl Config {
|
|
|
|
"log level (error, warn, info, debug, trace)",
|
|
|
|
"log level (error, warn, info, debug, trace)",
|
|
|
|
"LEVEL",
|
|
|
|
"LEVEL",
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
opts.optopt("o", "out", "stdout path", "STDOUT");
|
|
|
|
|
|
|
|
opts.optopt("e", "err", "stderr path", "STDERR");
|
|
|
|
opts.optflag("h", "help", "print this help menu");
|
|
|
|
opts.optflag("h", "help", "print this help menu");
|
|
|
|
|
|
|
|
|
|
|
|
let matches = match opts.parse(&args[1..]) {
|
|
|
|
let matches = match opts.parse(&args[1..]) {
|
|
|
@ -49,6 +53,30 @@ impl Config {
|
|
|
|
PathBuf::from(".")
|
|
|
|
PathBuf::from(".")
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let stdout = if let Some(dir) = matches.opt_str("o") {
|
|
|
|
|
|
|
|
PathBuf::from(dir)
|
|
|
|
|
|
|
|
} else if let Some(mut dir) = config_dir() {
|
|
|
|
|
|
|
|
dir.push("sup");
|
|
|
|
|
|
|
|
dir.push("stdout.log");
|
|
|
|
|
|
|
|
dir
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
let mut p = PathBuf::from(".");
|
|
|
|
|
|
|
|
p.push("stdout.log");
|
|
|
|
|
|
|
|
p
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let stderr = if let Some(dir) = matches.opt_str("e") {
|
|
|
|
|
|
|
|
PathBuf::from(dir)
|
|
|
|
|
|
|
|
} else if let Some(mut dir) = config_dir() {
|
|
|
|
|
|
|
|
dir.push("sup");
|
|
|
|
|
|
|
|
dir.push("stderr.log");
|
|
|
|
|
|
|
|
dir
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
let mut p = PathBuf::from(".");
|
|
|
|
|
|
|
|
p.push("stderr.log");
|
|
|
|
|
|
|
|
p
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
let mut log_level: LevelFilter = LevelFilter::Info;
|
|
|
|
let mut log_level: LevelFilter = LevelFilter::Info;
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(raw_level) = matches.opt_str("l") {
|
|
|
|
if let Some(raw_level) = matches.opt_str("l") {
|
|
|
@ -69,6 +97,8 @@ impl Config {
|
|
|
|
Config {
|
|
|
|
Config {
|
|
|
|
config_directory,
|
|
|
|
config_directory,
|
|
|
|
log_level,
|
|
|
|
log_level,
|
|
|
|
|
|
|
|
stdout,
|
|
|
|
|
|
|
|
stderr,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|