From 49bd8ead505e938346110cc17b6f859d04dfca13 Mon Sep 17 00:00:00 2001 From: Fuad Ismail Date: Mon, 25 Nov 2024 13:26:35 +0700 Subject: [PATCH] dmesg: parse time-format command line argument. --- src/uu/dmesg/src/dmesg.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/uu/dmesg/src/dmesg.rs b/src/uu/dmesg/src/dmesg.rs index 58c4d57..5392e67 100644 --- a/src/uu/dmesg/src/dmesg.rs +++ b/src/uu/dmesg/src/dmesg.rs @@ -27,6 +27,22 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> { if matches.get_flag(options::JSON) { dmesg.output_format = OutputFormat::Json; } + if let Some(time_format) = matches.get_one::(options::TIME_FORMAT) { + match &time_format[..] { + "delta" => dmesg.time_format = TimeFormat::Delta, + "reltime" => dmesg.time_format = TimeFormat::Reltime, + "ctime" => dmesg.time_format = TimeFormat::Ctime, + "notime" => dmesg.time_format = TimeFormat::Notime, + "iso" => dmesg.time_format = TimeFormat::Iso, + "raw" => dmesg.time_format = TimeFormat::Raw, + _ => { + return Err(USimpleError::new( + 1, + format!("unknown time format: {time_format}"), + )) + } + } + } dmesg.parse()?.print(); Ok(()) } @@ -159,6 +175,7 @@ enum TimeFormat { Delta, Reltime, Ctime, + Notime, Iso, Raw, }