From b816d2aa888fa2eb2fe48ad6e08776fa8d4069fb Mon Sep 17 00:00:00 2001 From: arabian Date: Sat, 14 Feb 2026 15:43:17 +0300 Subject: [PATCH] feat: get daemon's version using pwsp-cli pwsp-cli get daemon-version --- src/bin/cli.rs | 3 +++ src/types/commands.rs | 11 ++++++++++- src/types/socket.rs | 4 ++++ src/utils/commands.rs | 1 + 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/bin/cli.rs b/src/bin/cli.rs index c155632..3981ad9 100644 --- a/src/bin/cli.rs +++ b/src/bin/cli.rs @@ -92,6 +92,8 @@ enum GetCommands { Input, /// All audio inputs Inputs, + /// Version of the daemon + DaemonVersion, /// Full player state FullState, } @@ -148,6 +150,7 @@ async fn main() -> Result<(), Box> { GetCommands::Tracks => Request::get_tracks(), GetCommands::Input => Request::get_input(), GetCommands::Inputs => Request::get_inputs(), + GetCommands::DaemonVersion => Request::get_daemon_version(), GetCommands::FullState => Request::get_full_state(), }, Commands::Set { parameter } => match parameter { diff --git a/src/types/commands.rs b/src/types/commands.rs index b8f1cba..a93bbe4 100644 --- a/src/types/commands.rs +++ b/src/types/commands.rs @@ -82,6 +82,8 @@ pub struct ToggleLoopCommand { pub id: Option, } +pub struct GetDaemonVersionCommand {} + pub struct GetFullStateCommand {} #[async_trait] @@ -347,6 +349,13 @@ impl Executable for ToggleLoopCommand { } } +#[async_trait] +impl Executable for GetDaemonVersionCommand { + async fn execute(&self) -> Response { + Response::new(true, env!("CARGO_PKG_VERSION")) + } +} + #[async_trait] impl Executable for GetFullStateCommand { async fn execute(&self) -> Response { @@ -374,7 +383,7 @@ impl Executable for GetFullStateCommand { tracks: audio_player.get_tracks(), volume: audio_player.volume, current_input: current_input_nick, - all_inputs, + all_inputs: all_inputs, }; Response::new(true, serde_json::to_string(&full_state).unwrap()) diff --git a/src/types/socket.rs b/src/types/socket.rs index d762842..390e917 100644 --- a/src/types/socket.rs +++ b/src/types/socket.rs @@ -156,6 +156,10 @@ impl Request { Request::new("toggle_loop", args) } + pub fn get_daemon_version() -> Self { + Request::new("get_daemon_version", vec![]) + } + pub fn get_full_state() -> Self { Request::new("get_full_state", vec![]) } diff --git a/src/utils/commands.rs b/src/utils/commands.rs index 911b23a..7e68d67 100644 --- a/src/utils/commands.rs +++ b/src/utils/commands.rs @@ -69,6 +69,7 @@ pub fn parse_command(request: &Request) -> Option> { Some(Box::new(SetLoopCommand { enabled, id })) } "toggle_loop" => Some(Box::new(ToggleLoopCommand { id })), + "get_daemon_version" => Some(Box::new(GetDaemonVersionCommand {})), "get_full_state" => Some(Box::new(GetFullStateCommand {})), _ => None, }