feat: CLI support for listing artists
This commit is contained in:
+37
-1
@@ -13,6 +13,7 @@ use tokio_util::sync::CancellationToken;
|
||||
use veil::Redact;
|
||||
|
||||
use crate::cli::Command;
|
||||
use crate::models::servarr_data::lidarr::lidarr_data::ActiveLidarrBlock;
|
||||
use crate::models::servarr_data::radarr::radarr_data::{ActiveRadarrBlock, RadarrData};
|
||||
use crate::models::servarr_data::sonarr::sonarr_data::{ActiveSonarrBlock, SonarrData};
|
||||
use crate::models::servarr_models::KeybindingItem;
|
||||
@@ -96,6 +97,26 @@ impl App<'_> {
|
||||
server_tabs.extend(sonarr_tabs);
|
||||
}
|
||||
|
||||
if let Some(lidarr_configs) = config.lidarr {
|
||||
let mut unnamed_idx = 0;
|
||||
let lidarr_tabs = lidarr_configs.into_iter().map(|lidarr_config| {
|
||||
let name = if let Some(name) = lidarr_config.name.clone() {
|
||||
name
|
||||
} else {
|
||||
unnamed_idx += 1;
|
||||
format!("Lidarr {unnamed_idx}")
|
||||
};
|
||||
|
||||
TabRoute {
|
||||
title: name,
|
||||
route: ActiveLidarrBlock::Artists.into(),
|
||||
contextual_help: None,
|
||||
config: Some(lidarr_config),
|
||||
}
|
||||
});
|
||||
server_tabs.extend(lidarr_tabs);
|
||||
}
|
||||
|
||||
let weight_sorted_tabs = server_tabs
|
||||
.into_iter()
|
||||
.sorted_by(|tab1, tab2| {
|
||||
@@ -303,13 +324,14 @@ pub struct Data<'a> {
|
||||
#[derive(Debug, Deserialize, Serialize, Default, Clone)]
|
||||
pub struct AppConfig {
|
||||
pub theme: Option<String>,
|
||||
pub lidarr: Option<Vec<ServarrConfig>>,
|
||||
pub radarr: Option<Vec<ServarrConfig>>,
|
||||
pub sonarr: Option<Vec<ServarrConfig>>,
|
||||
}
|
||||
|
||||
impl AppConfig {
|
||||
pub fn validate(&self) {
|
||||
if self.radarr.is_none() && self.sonarr.is_none() {
|
||||
if self.lidarr.is_none() && self.radarr.is_none() && self.sonarr.is_none() {
|
||||
log_and_print_error(
|
||||
"No Servarr configuration provided in the specified configuration file".to_owned(),
|
||||
);
|
||||
@@ -323,6 +345,10 @@ impl AppConfig {
|
||||
if let Some(sonarr_configs) = &self.sonarr {
|
||||
sonarr_configs.iter().for_each(|config| config.validate());
|
||||
}
|
||||
|
||||
if let Some(lidarr_configs) = &self.lidarr {
|
||||
lidarr_configs.iter().for_each(|config| config.validate());
|
||||
}
|
||||
}
|
||||
|
||||
pub fn verify_config_present_for_cli(&self, command: &Command) {
|
||||
@@ -340,6 +366,10 @@ impl AppConfig {
|
||||
msg("Sonarr");
|
||||
process::exit(1);
|
||||
}
|
||||
Command::Lidarr(_) if self.lidarr.is_none() => {
|
||||
msg("Lidarr");
|
||||
process::exit(1);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
@@ -356,6 +386,12 @@ impl AppConfig {
|
||||
sonarr_config.post_process_initialization();
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(lidarr_configs) = self.lidarr.as_mut() {
|
||||
for lidarr_config in lidarr_configs {
|
||||
lidarr_config.post_process_initialization();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user