feat(cli): Support for deleting an episode file from disk
This commit is contained in:
@@ -33,6 +33,11 @@ pub enum SonarrDeleteCommand {
|
|||||||
#[arg(long, help = "The ID of the download to delete", required = true)]
|
#[arg(long, help = "The ID of the download to delete", required = true)]
|
||||||
download_id: i64,
|
download_id: i64,
|
||||||
},
|
},
|
||||||
|
#[command(about = "Delete the specified episode file from disk")]
|
||||||
|
EpisodeFile {
|
||||||
|
#[arg(long, help = "The ID of the episode file to delete", required = true)]
|
||||||
|
episode_file_id: i64,
|
||||||
|
},
|
||||||
#[command(about = "Delete the indexer with the given ID")]
|
#[command(about = "Delete the indexer with the given ID")]
|
||||||
Indexer {
|
Indexer {
|
||||||
#[arg(long, help = "The ID of the indexer to delete", required = true)]
|
#[arg(long, help = "The ID of the indexer to delete", required = true)]
|
||||||
@@ -100,6 +105,13 @@ impl<'a, 'b> CliCommandHandler<'a, 'b, SonarrDeleteCommand> for SonarrDeleteComm
|
|||||||
.await?;
|
.await?;
|
||||||
serde_json::to_string_pretty(&resp)?
|
serde_json::to_string_pretty(&resp)?
|
||||||
}
|
}
|
||||||
|
SonarrDeleteCommand::EpisodeFile { episode_file_id } => {
|
||||||
|
let resp = self
|
||||||
|
.network
|
||||||
|
.handle_network_event(SonarrEvent::DeleteEpisodeFile(Some(episode_file_id)).into())
|
||||||
|
.await?;
|
||||||
|
serde_json::to_string_pretty(&resp)?
|
||||||
|
}
|
||||||
SonarrDeleteCommand::Indexer { indexer_id } => {
|
SonarrDeleteCommand::Indexer { indexer_id } => {
|
||||||
let resp = self
|
let resp = self
|
||||||
.network
|
.network
|
||||||
|
|||||||
@@ -93,6 +93,39 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_delete_episode_file_requires_arguments() {
|
||||||
|
let result =
|
||||||
|
Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "episode-file"]);
|
||||||
|
|
||||||
|
assert!(result.is_err());
|
||||||
|
assert_eq!(
|
||||||
|
result.unwrap_err().kind(),
|
||||||
|
ErrorKind::MissingRequiredArgument
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_delete_episode_file_success() {
|
||||||
|
let expected_args = SonarrDeleteCommand::EpisodeFile { episode_file_id: 1 };
|
||||||
|
|
||||||
|
let result = Cli::try_parse_from([
|
||||||
|
"managarr",
|
||||||
|
"sonarr",
|
||||||
|
"delete",
|
||||||
|
"episode-file",
|
||||||
|
"--episode-file-id",
|
||||||
|
"1",
|
||||||
|
]);
|
||||||
|
|
||||||
|
assert!(result.is_ok());
|
||||||
|
|
||||||
|
if let Some(Command::Sonarr(SonarrCommand::Delete(delete_command))) = result.unwrap().command
|
||||||
|
{
|
||||||
|
assert_eq!(delete_command, expected_args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_delete_indexer_requires_arguments() {
|
fn test_delete_indexer_requires_arguments() {
|
||||||
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "indexer"]);
|
let result = Cli::command().try_get_matches_from(["managarr", "sonarr", "delete", "indexer"]);
|
||||||
|
|||||||
Reference in New Issue
Block a user