diff --git a/src/cli.rs b/src/cli.rs index 4dcaa45..0230610 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -5,7 +5,7 @@ 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"; @@ -29,5 +29,10 @@ pub fn build_cli() -> Command { .required(false) .value_parser(value_parser!(PathBuf)), ) + .arg( + arg!(--timestamp "Add timestamp to log output.") + .action(ArgAction::SetTrue) + .required(false), + ) .arg(arg!(-v --verbose ... "Verbosity level.")) } diff --git a/src/main.rs b/src/main.rs index 3112e81..e1a0bcb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -51,9 +51,15 @@ async fn main() -> io::Result<()> { } //pretty_env_logger::init(); - pretty_env_logger::formatted_timed_builder() - .parse_env("RUST_LOG") - .init(); + if matches.get_flag("timestamp") { + pretty_env_logger::formatted_timed_builder() + .parse_env("RUST_LOG") + .init(); + } else { + pretty_env_logger::formatted_builder() + .parse_env("RUST_LOG") + .init(); + } if let Some(name) = matches.get_one::("name") { host_name = name.to_owned();