feat: --timestamp
flag
Signed-off-by: Christina Sørensen <christina@cafkafk.com>
This commit is contained in:
parent
74fe2a3b4a
commit
4f5e6159fe
2 changed files with 15 additions and 4 deletions
|
@ -5,7 +5,7 @@
|
||||||
|
|
||||||
use std::{cell::OnceCell, sync::OnceLock};
|
use std::{cell::OnceCell, sync::OnceLock};
|
||||||
|
|
||||||
use clap::{arg, command, crate_authors, value_parser, Arg, Command};
|
use clap::{arg, command, crate_authors, value_parser, Arg, ArgAction, Command};
|
||||||
|
|
||||||
const DEFAULT_CACHE: &str = "cache.nixos.org";
|
const DEFAULT_CACHE: &str = "cache.nixos.org";
|
||||||
|
|
||||||
|
@ -29,5 +29,10 @@ pub fn build_cli() -> Command {
|
||||||
.required(false)
|
.required(false)
|
||||||
.value_parser(value_parser!(PathBuf)),
|
.value_parser(value_parser!(PathBuf)),
|
||||||
)
|
)
|
||||||
|
.arg(
|
||||||
|
arg!(--timestamp "Add timestamp to log output.")
|
||||||
|
.action(ArgAction::SetTrue)
|
||||||
|
.required(false),
|
||||||
|
)
|
||||||
.arg(arg!(-v --verbose ... "Verbosity level."))
|
.arg(arg!(-v --verbose ... "Verbosity level."))
|
||||||
}
|
}
|
||||||
|
|
12
src/main.rs
12
src/main.rs
|
@ -51,9 +51,15 @@ async fn main() -> io::Result<()> {
|
||||||
}
|
}
|
||||||
|
|
||||||
//pretty_env_logger::init();
|
//pretty_env_logger::init();
|
||||||
pretty_env_logger::formatted_timed_builder()
|
if matches.get_flag("timestamp") {
|
||||||
.parse_env("RUST_LOG")
|
pretty_env_logger::formatted_timed_builder()
|
||||||
.init();
|
.parse_env("RUST_LOG")
|
||||||
|
.init();
|
||||||
|
} else {
|
||||||
|
pretty_env_logger::formatted_builder()
|
||||||
|
.parse_env("RUST_LOG")
|
||||||
|
.init();
|
||||||
|
}
|
||||||
|
|
||||||
if let Some(name) = matches.get_one::<String>("name") {
|
if let Some(name) = matches.get_one::<String>("name") {
|
||||||
host_name = name.to_owned();
|
host_name = name.to_owned();
|
||||||
|
|
Loading…
Reference in a new issue