feat(cli): Support for refreshing Sonarr downloads
This commit is contained in:
@@ -28,6 +28,8 @@ pub enum SonarrRefreshCommand {
|
|||||||
)]
|
)]
|
||||||
series_id: i64,
|
series_id: i64,
|
||||||
},
|
},
|
||||||
|
#[command(about = "Refresh all downloads in Sonarr")]
|
||||||
|
Downloads,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<SonarrRefreshCommand> for Command {
|
impl From<SonarrRefreshCommand> for Command {
|
||||||
@@ -73,6 +75,13 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, SonarrRefreshCommand>
|
|||||||
.await?;
|
.await?;
|
||||||
serde_json::to_string_pretty(&resp)?
|
serde_json::to_string_pretty(&resp)?
|
||||||
}
|
}
|
||||||
|
SonarrRefreshCommand::Downloads => {
|
||||||
|
let resp = self
|
||||||
|
.network
|
||||||
|
.handle_network_event(SonarrEvent::UpdateDownloads.into())
|
||||||
|
.await?;
|
||||||
|
serde_json::to_string_pretty(&resp)?
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(result)
|
Ok(result)
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ mod tests {
|
|||||||
use rstest::rstest;
|
use rstest::rstest;
|
||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
fn test_refresh_commands_have_no_arg_requirements(#[values("all-series")] subcommand: &str) {
|
fn test_refresh_commands_have_no_arg_requirements(
|
||||||
|
#[values("all-series", "downloads")] subcommand: &str,
|
||||||
|
) {
|
||||||
let result =
|
let result =
|
||||||
Cli::command().try_get_matches_from(["managarr", "sonarr", "refresh", subcommand]);
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "refresh", subcommand]);
|
||||||
|
|
||||||
@@ -85,6 +87,7 @@ mod tests {
|
|||||||
|
|
||||||
#[rstest]
|
#[rstest]
|
||||||
#[case(SonarrRefreshCommand::AllSeries, SonarrEvent::UpdateAllSeries)]
|
#[case(SonarrRefreshCommand::AllSeries, SonarrEvent::UpdateAllSeries)]
|
||||||
|
#[case(SonarrRefreshCommand::Downloads, SonarrEvent::UpdateDownloads)]
|
||||||
#[tokio::test]
|
#[tokio::test]
|
||||||
async fn test_handle_refresh_command(
|
async fn test_handle_refresh_command(
|
||||||
#[case] refresh_command: SonarrRefreshCommand,
|
#[case] refresh_command: SonarrRefreshCommand,
|
||||||
|
|||||||
Reference in New Issue
Block a user