feat(sonarr): Added blocklist commands (List, Clear, Delete)
This commit is contained in:
+26
-1
@@ -2,14 +2,20 @@ use std::sync::Arc;
|
||||
|
||||
use anyhow::Result;
|
||||
use clap::Subcommand;
|
||||
use delete_command_handler::{SonarrDeleteCommand, SonarrDeleteCommandHandler};
|
||||
use get_command_handler::{SonarrGetCommand, SonarrGetCommandHandler};
|
||||
use list_command_handler::{SonarrListCommand, SonarrListCommandHandler};
|
||||
use tokio::sync::Mutex;
|
||||
|
||||
use crate::{app::App, network::NetworkTrait};
|
||||
use crate::{
|
||||
app::App,
|
||||
execute_network_event,
|
||||
network::{sonarr_network::SonarrEvent, NetworkTrait},
|
||||
};
|
||||
|
||||
use super::{CliCommandHandler, Command};
|
||||
|
||||
mod delete_command_handler;
|
||||
mod get_command_handler;
|
||||
mod list_command_handler;
|
||||
|
||||
@@ -19,6 +25,11 @@ mod sonarr_command_tests;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Subcommand)]
|
||||
pub enum SonarrCommand {
|
||||
#[command(
|
||||
subcommand,
|
||||
about = "Commands to delete resources from your Sonarr instance"
|
||||
)]
|
||||
Delete(SonarrDeleteCommand),
|
||||
#[command(
|
||||
subcommand,
|
||||
about = "Commands to fetch details of the resources in your Sonarr instance"
|
||||
@@ -29,6 +40,8 @@ pub enum SonarrCommand {
|
||||
about = "Commands to list attributes from your Sonarr instance"
|
||||
)]
|
||||
List(SonarrListCommand),
|
||||
#[command(about = "Clear the blocklist")]
|
||||
ClearBlocklist,
|
||||
}
|
||||
|
||||
impl From<SonarrCommand> for Command {
|
||||
@@ -58,6 +71,11 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, SonarrCommand> for SonarrCliHandler<'a, '
|
||||
|
||||
async fn handle(self) -> Result<()> {
|
||||
match self.command {
|
||||
SonarrCommand::Delete(delete_command) => {
|
||||
SonarrDeleteCommandHandler::with(self.app, delete_command, self.network)
|
||||
.handle()
|
||||
.await?
|
||||
}
|
||||
SonarrCommand::Get(get_command) => {
|
||||
SonarrGetCommandHandler::with(self.app, get_command, self.network)
|
||||
.handle()
|
||||
@@ -68,6 +86,13 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, SonarrCommand> for SonarrCliHandler<'a, '
|
||||
.handle()
|
||||
.await?
|
||||
}
|
||||
SonarrCommand::ClearBlocklist => {
|
||||
self
|
||||
.network
|
||||
.handle_network_event(SonarrEvent::GetBlocklist.into())
|
||||
.await?;
|
||||
execute_network_event!(self, SonarrEvent::ClearBlocklist);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
Reference in New Issue
Block a user