From a7826e2fb59d6b0098fd1aa4a4d9d03a11e3afbd Mon Sep 17 00:00:00 2001 From: marcelarie Date: Thu, 17 Oct 2024 16:53:25 +0200 Subject: [PATCH] feat: add date and time to generated alias file using chrono --- Cargo.lock | 1 + Cargo.toml | 1 + src/output/writer.rs | 9 +++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 20a08b8..5e55104 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1533,6 +1533,7 @@ dependencies = [ name = "nu-alias-converter" version = "0.1.0" dependencies = [ + "chrono", "nu-cmd-lang", "nu-command", "nu-parser", diff --git a/Cargo.toml b/Cargo.toml index 365f5f2..190e400 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,6 +4,7 @@ version = "0.1.0" edition = "2021" [dependencies] +chrono = "0.4.38" nu-cmd-lang = "0.98.0" nu-command = "0.98.0" nu-parser = "0.98.0" diff --git a/src/output/writer.rs b/src/output/writer.rs index d83f343..529d1ab 100644 --- a/src/output/writer.rs +++ b/src/output/writer.rs @@ -20,8 +20,13 @@ pub fn process_and_write_aliases( File::create(&output_file_path).expect("Error creating output file"); let mut writer = BufWriter::new(file); - writeln!(writer, "# Aliases auto generated by nu-alias-converter\n") - .expect("Error writing to file"); + // add date and time + writeln!( + writer, + "# Aliases auto generated by nu-alias-converter on {}", + chrono::Local::now().format("%Y-%m-%d %H:%M:%S") + ) + .expect("Error writing to file"); let results: Vec = aliases.par_iter().map(|alias| { let command_ignores = &alias_ignore_result.command_ignores;