diff --git a/Cargo.toml b/Cargo.toml index a2c33b32..95704db2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,6 @@ version = "0.1.0" edition = "2021" [dependencies] -chrono = "0.4.33" clap = { version = "4.5.16", features = ["derive"] } crossterm = "0.27.0" ego-tree = "0.6.2" @@ -19,6 +18,9 @@ toml = "0.8.19" which = "6.0.3" unicode-width = "0.1.13" +[build-dependencies] +chrono = "0.4.33" + [[bin]] name = "linutil" path = "src/main.rs" diff --git a/build.rs b/build.rs index dc9c06dd..e6e6600f 100644 --- a/build.rs +++ b/build.rs @@ -1,4 +1,9 @@ fn main() { // Rebuild program if any file in commands directory changes. println!("cargo:rerun-if-changed=src/commands"); + // Add current date as a variable to be displayed in the 'Linux Toolbox' text. + println!( + "cargo:rustc-env=BUILD_DATE={}", + chrono::Local::now().format("%Y-%m-%d") + ); } diff --git a/src/state.rs b/src/state.rs index cbeb0bb0..432a5af2 100644 --- a/src/state.rs +++ b/src/state.rs @@ -137,10 +137,11 @@ impl AppState { } else { Style::new() }) - .block(Block::default().borders(Borders::ALL).title(format!( - "Linux Toolbox - {}", - chrono::Local::now().format("%Y-%m-%d") - ))) + .block( + Block::default() + .borders(Borders::ALL) + .title(format!("Linux Toolbox - {}", env!("BUILD_DATE"))), + ) .scroll_padding(1); frame.render_stateful_widget(list, chunks[1], &mut self.selection);