feat(readarr): fetch the Readarr host config and expose it on the CLI

This commit is contained in:
Dark-Alex-17 committed 2026-08-20 16:07:33 -06:00
1 parent 520b422dcc
commit 1072585903
6 files changed
+123 -3

No files matched your search

+9
View File
@@ -18,6 +18,8 @@ mod get_command_handler_tests;
#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
pub enum ReadarrGetCommand {
#[command(about = "Fetch the host config for your Readarr instance")]
HostConfig,
#[command(about = "Get the system status")]
SystemStatus,
}
@@ -49,6 +51,13 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, ReadarrGetCommand> for ReadarrGetCommandH
async fn handle(self) -> Result<String> {
let result = match self.command {
ReadarrGetCommand::HostConfig => {
let resp = self
.network
.handle_network_event(ReadarrEvent::GetHostConfig.into())
.await?;
serde_json::to_string_pretty(&resp)?
}
ReadarrGetCommand::SystemStatus => {
let resp = self
.network
+26 -1
View File
@@ -22,7 +22,9 @@ mod tests {
use rstest::rstest;
#[rstest]
fn test_get_commands_have_no_arg_requirements(#[values("system-status")] subcommand: &str) {
fn test_get_commands_have_no_arg_requirements(
#[values("host-config", "system-status")] subcommand: &str,
) {
let result = Cli::command().try_get_matches_from(["managarr", "readarr", "get", subcommand]);
assert_ok!(&result);
@@ -46,6 +48,29 @@ mod tests {
network::{MockNetworkTrait, NetworkEvent, readarr_network::ReadarrEvent},
};
#[tokio::test]
async fn test_handle_get_host_config_command() {
let mut mock_network = MockNetworkTrait::new();
mock_network
.expect_handle_network_event()
.with(eq::<NetworkEvent>(ReadarrEvent::GetHostConfig.into()))
.times(1)
.returning(|_| {
Ok(Serdeable::Readarr(ReadarrSerdeable::Value(
json!({"testResponse": "response"}),
)))
});
let app_arc = Arc::new(Mutex::new(App::test_default()));
let get_host_config_command = ReadarrGetCommand::HostConfig;
let result =
ReadarrGetCommandHandler::with(&app_arc, get_host_config_command, &mut mock_network)
.handle()
.await;
assert_ok!(&result);
}
#[tokio::test]
async fn test_handle_get_system_status_command() {
let mut mock_network = MockNetworkTrait::new();