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 --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/cli.rs | 2 +- src/state.rs | 15 +++++++++++++-- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 91b1eb3..0178988 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -314,7 +314,7 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98" [[package]] name = "mood" -version = "0.5.0" +version = "0.6.0" dependencies = [ "chrono", "directories", diff --git a/Cargo.toml b/Cargo.toml index 762f2d5..27c2bb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mood" -version = "0.5.0" +version = "0.6.0" description = "A music player governed by your moods." edition = "2024" license = "GPL-3.0-or-later" 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