From 4b912fbb21eff1fd8b7178619a402fbd4dacebfd Mon Sep 17 00:00:00 2001 From: tslil Date: Thu, 16 Jul 2026 09:01:33 +0100 Subject: add version to state --- src/cli.rs | 2 +- src/state.rs | 15 +++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cli.rs b/src/cli.rs index b408dae..29ea2cf 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -10,7 +10,7 @@ pub enum Action { } const NAME: &str = env!("CARGO_PKG_NAME"); -const VERSION: &str = env!("CARGO_PKG_VERSION"); +pub const VERSION: &str = env!("CARGO_PKG_VERSION"); const DESCRIPTION: &str = env!("CARGO_PKG_DESCRIPTION"); fn print_help() { diff --git a/src/state.rs b/src/state.rs index 47998f3..aae22b0 100644 --- a/src/state.rs +++ b/src/state.rs @@ -4,7 +4,7 @@ use directories::ProjectDirs; use expanduser::expanduser; use serde::{Deserialize, Serialize}; -use crate::{albums, config::Config, intuition::Intuition, trajectory::Trajectory}; +use crate::{albums, cli::VERSION, config::Config, intuition::Intuition, trajectory::Trajectory}; fn default_state_path() -> String { let name = "mood.json.zstd"; @@ -18,10 +18,21 @@ fn default_state_path() -> String { .unwrap_or(format!("~/.config/mood/{name}")) } -#[derive(Serialize, Deserialize, Default)] +#[derive(Serialize, Deserialize)] pub struct State { trajectory: Trajectory, intuition: Intuition, + version: String, +} + +impl Default for State { + fn default() -> State { + State { + trajectory: Trajectory::default(), + intuition: Intuition::default(), + version: VERSION.to_string(), + } + } } impl State { -- cgit v1.2.3