style: Addressed updated linter complaints
This commit is contained in:
@@ -513,8 +513,7 @@ mod tests {
|
|||||||
let api_token = "thisisatest".to_owned();
|
let api_token = "thisisatest".to_owned();
|
||||||
let api_token_file = "/root/.config/api_token".to_owned();
|
let api_token_file = "/root/.config/api_token".to_owned();
|
||||||
let ssl_cert_path = "/some/path".to_owned();
|
let ssl_cert_path = "/some/path".to_owned();
|
||||||
let expected_str = format!("ServarrConfig {{ name: Some(\"{}\"), host: Some(\"{}\"), port: Some({}), uri: Some(\"{}\"), weight: Some({}), api_token: Some(\"***********\"), api_token_file: Some(\"{}\"), ssl_cert_path: Some(\"{}\") }}",
|
let expected_str = format!("ServarrConfig {{ name: Some(\"{name}\"), host: Some(\"{host}\"), port: Some({port}), uri: Some(\"{uri}\"), weight: Some({weight}), api_token: Some(\"***********\"), api_token_file: Some(\"{api_token_file}\"), ssl_cert_path: Some(\"{ssl_cert_path}\") }}");
|
||||||
name, host, port, uri, weight, api_token_file, ssl_cert_path);
|
|
||||||
let servarr_config = ServarrConfig {
|
let servarr_config = ServarrConfig {
|
||||||
name: Some(name),
|
name: Some(name),
|
||||||
host: Some(host),
|
host: Some(host),
|
||||||
|
|||||||
+5
-7
@@ -63,7 +63,7 @@ impl App<'_> {
|
|||||||
name
|
name
|
||||||
} else {
|
} else {
|
||||||
idx += 1;
|
idx += 1;
|
||||||
format!("Radarr {}", idx)
|
format!("Radarr {idx}")
|
||||||
};
|
};
|
||||||
|
|
||||||
server_tabs.push(TabRoute {
|
server_tabs.push(TabRoute {
|
||||||
@@ -84,7 +84,7 @@ impl App<'_> {
|
|||||||
name
|
name
|
||||||
} else {
|
} else {
|
||||||
idx += 1;
|
idx += 1;
|
||||||
format!("Sonarr {}", idx)
|
format!("Sonarr {idx}")
|
||||||
};
|
};
|
||||||
|
|
||||||
server_tabs.push(TabRoute {
|
server_tabs.push(TabRoute {
|
||||||
@@ -296,8 +296,7 @@ impl AppConfig {
|
|||||||
pub fn verify_config_present_for_cli(&self, command: &Command) {
|
pub fn verify_config_present_for_cli(&self, command: &Command) {
|
||||||
let msg = |servarr: &str| {
|
let msg = |servarr: &str| {
|
||||||
log_and_print_error(format!(
|
log_and_print_error(format!(
|
||||||
"{} configuration missing; Unable to run any {} commands.",
|
"{servarr} configuration missing; Unable to run any {servarr} commands."
|
||||||
servarr, servarr
|
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
match command {
|
match command {
|
||||||
@@ -368,8 +367,7 @@ impl ServarrConfig {
|
|||||||
if let Some(api_token_file) = self.api_token_file.as_ref() {
|
if let Some(api_token_file) = self.api_token_file.as_ref() {
|
||||||
if !PathBuf::from(api_token_file).exists() {
|
if !PathBuf::from(api_token_file).exists() {
|
||||||
log_and_print_error(format!(
|
log_and_print_error(format!(
|
||||||
"The specified {} API token file does not exist",
|
"The specified {api_token_file} API token file does not exist"
|
||||||
api_token_file
|
|
||||||
));
|
));
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
@@ -398,7 +396,7 @@ impl Default for ServarrConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn log_and_print_error(error: String) {
|
pub fn log_and_print_error(error: String) {
|
||||||
error!("{}", error);
|
error!("{error}");
|
||||||
eprintln!("error: {}", error.red());
|
eprintln!("error: {}", error.red());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -663,7 +663,7 @@ mod tests {
|
|||||||
Collection {
|
Collection {
|
||||||
id: 3,
|
id: 3,
|
||||||
title: "test 1".into(),
|
title: "test 1".into(),
|
||||||
movies: Some(iter::repeat(CollectionMovie::default()).take(3).collect()),
|
movies: Some(iter::repeat_n(CollectionMovie::default(), 3).collect()),
|
||||||
root_folder_path: Some("/nfs/movies".into()),
|
root_folder_path: Some("/nfs/movies".into()),
|
||||||
quality_profile_id: 1,
|
quality_profile_id: 1,
|
||||||
search_on_add: false,
|
search_on_add: false,
|
||||||
@@ -673,7 +673,7 @@ mod tests {
|
|||||||
Collection {
|
Collection {
|
||||||
id: 2,
|
id: 2,
|
||||||
title: "test 2".into(),
|
title: "test 2".into(),
|
||||||
movies: Some(iter::repeat(CollectionMovie::default()).take(7).collect()),
|
movies: Some(iter::repeat_n(CollectionMovie::default(), 7).collect()),
|
||||||
root_folder_path: Some("/htpc/movies".into()),
|
root_folder_path: Some("/htpc/movies".into()),
|
||||||
quality_profile_id: 3,
|
quality_profile_id: 3,
|
||||||
search_on_add: true,
|
search_on_add: true,
|
||||||
@@ -683,7 +683,7 @@ mod tests {
|
|||||||
Collection {
|
Collection {
|
||||||
id: 1,
|
id: 1,
|
||||||
title: "test 3".into(),
|
title: "test 3".into(),
|
||||||
movies: Some(iter::repeat(CollectionMovie::default()).take(1).collect()),
|
movies: Some(iter::repeat_n(CollectionMovie::default(), 1).collect()),
|
||||||
root_folder_path: Some("/nfs/some/stupidly/long/path/to/test/with".into()),
|
root_folder_path: Some("/nfs/some/stupidly/long/path/to/test/with".into()),
|
||||||
quality_profile_id: 1,
|
quality_profile_id: 1,
|
||||||
search_on_add: false,
|
search_on_add: false,
|
||||||
|
|||||||
@@ -1128,7 +1128,7 @@ impl Network<'_, '_> {
|
|||||||
info!("Fetching Radarr logs");
|
info!("Fetching Radarr logs");
|
||||||
let event = RadarrEvent::GetLogs(events);
|
let event = RadarrEvent::GetLogs(events);
|
||||||
|
|
||||||
let params = format!("pageSize={}&sortDirection=descending&sortKey=time", events);
|
let params = format!("pageSize={events}&sortDirection=descending&sortKey=time");
|
||||||
let request_props = self
|
let request_props = self
|
||||||
.request_props_from(event, RequestMethod::Get, None::<()>, None, Some(params))
|
.request_props_from(event, RequestMethod::Get, None::<()>, None, Some(params))
|
||||||
.await;
|
.await;
|
||||||
@@ -1215,7 +1215,7 @@ impl Network<'_, '_> {
|
|||||||
.to_owned();
|
.to_owned();
|
||||||
let imdb_rating = if let Some(rating) = ratings.imdb {
|
let imdb_rating = if let Some(rating) = ratings.imdb {
|
||||||
if let Some(value) = rating.value.as_f64() {
|
if let Some(value) = rating.value.as_f64() {
|
||||||
format!("{:.1}", value)
|
format!("{value:.1}")
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
String::new()
|
||||||
}
|
}
|
||||||
@@ -1235,7 +1235,7 @@ impl Network<'_, '_> {
|
|||||||
|
|
||||||
let rotten_tomatoes_rating = if let Some(rating) = ratings.rotten_tomatoes {
|
let rotten_tomatoes_rating = if let Some(rating) = ratings.rotten_tomatoes {
|
||||||
if let Some(value) = rating.value.as_u64() {
|
if let Some(value) = rating.value.as_u64() {
|
||||||
format!("{}%", value)
|
format!("{value}%")
|
||||||
} else {
|
} else {
|
||||||
String::new()
|
String::new()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1447,7 +1447,7 @@ impl Network<'_, '_> {
|
|||||||
info!("Fetching all Sonarr history events");
|
info!("Fetching all Sonarr history events");
|
||||||
let event = SonarrEvent::GetHistory(events);
|
let event = SonarrEvent::GetHistory(events);
|
||||||
|
|
||||||
let params = format!("pageSize={}&sortDirection=descending&sortKey=date", events);
|
let params = format!("pageSize={events}&sortDirection=descending&sortKey=date");
|
||||||
let request_props = self
|
let request_props = self
|
||||||
.request_props_from(event, RequestMethod::Get, None::<()>, None, Some(params))
|
.request_props_from(event, RequestMethod::Get, None::<()>, None, Some(params))
|
||||||
.await;
|
.await;
|
||||||
@@ -1504,7 +1504,7 @@ impl Network<'_, '_> {
|
|||||||
info!("Fetching Sonarr logs");
|
info!("Fetching Sonarr logs");
|
||||||
let event = SonarrEvent::GetLogs(events);
|
let event = SonarrEvent::GetLogs(events);
|
||||||
|
|
||||||
let params = format!("pageSize={}&sortDirection=descending&sortKey=time", events);
|
let params = format!("pageSize={events}&sortDirection=descending&sortKey=time");
|
||||||
let request_props = self
|
let request_props = self
|
||||||
.request_props_from(event, RequestMethod::Get, None::<()>, None, Some(params))
|
.request_props_from(event, RequestMethod::Get, None::<()>, None, Some(params))
|
||||||
.await;
|
.await;
|
||||||
@@ -1678,10 +1678,7 @@ impl Network<'_, '_> {
|
|||||||
RequestMethod::Get,
|
RequestMethod::Get,
|
||||||
None::<()>,
|
None::<()>,
|
||||||
None,
|
None,
|
||||||
Some(format!(
|
Some(format!("seriesId={series_id}&seasonNumber={season_number}")),
|
||||||
"seriesId={}&seasonNumber={}",
|
|
||||||
series_id, season_number
|
|
||||||
)),
|
|
||||||
)
|
)
|
||||||
.await;
|
.await;
|
||||||
|
|
||||||
|
|||||||
@@ -353,7 +353,7 @@ fn draw_movie_crew(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
|||||||
.block(layout_block_top_border())
|
.block(layout_block_top_border())
|
||||||
.loading(app.is_loading)
|
.loading(app.is_loading)
|
||||||
.headers(["Crew Member", "Job", "Department"])
|
.headers(["Crew Member", "Job", "Department"])
|
||||||
.constraints(iter::repeat(Constraint::Ratio(1, 3)).take(3))
|
.constraints(iter::repeat_n(Constraint::Ratio(1, 3), 3))
|
||||||
.footer(help_footer);
|
.footer(help_footer);
|
||||||
|
|
||||||
f.render_widget(crew_table, area);
|
f.render_widget(crew_table, area);
|
||||||
|
|||||||
+9
-10
@@ -92,9 +92,11 @@ fn draw_stats_context(f: &mut Frame<'_>, app: &App<'_>, area: Rect) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
constraints.append(
|
constraints.append(
|
||||||
&mut iter::repeat(Constraint::Length(1))
|
&mut iter::repeat_n(
|
||||||
.take(disk_space_vec.len() + root_folders.items.len() + 1)
|
Constraint::Length(1),
|
||||||
.collect(),
|
disk_space_vec.len() + root_folders.items.len() + 1,
|
||||||
|
)
|
||||||
|
.collect(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let stat_item_areas = Layout::vertical(constraints).margin(1).split(area);
|
let stat_item_areas = Layout::vertical(constraints).margin(1).split(area);
|
||||||
@@ -175,13 +177,10 @@ fn draw_downloads_context(f: &mut Frame<'_>, app: &App<'_>, area: Rect) {
|
|||||||
|
|
||||||
let max_items = ((((area.height as f32 / 2.0).floor() * 2.0) as i32) / 2) - 1;
|
let max_items = ((((area.height as f32 / 2.0).floor() * 2.0) as i32) / 2) - 1;
|
||||||
let items = cmp::min(downloads_vec.len(), max_items.unsigned_abs() as usize);
|
let items = cmp::min(downloads_vec.len(), max_items.unsigned_abs() as usize);
|
||||||
let download_item_areas = Layout::vertical(
|
let download_item_areas =
|
||||||
iter::repeat(Constraint::Length(2))
|
Layout::vertical(iter::repeat_n(Constraint::Length(2), items).collect::<Vec<Constraint>>())
|
||||||
.take(items)
|
.margin(1)
|
||||||
.collect::<Vec<Constraint>>(),
|
.split(area);
|
||||||
)
|
|
||||||
.margin(1)
|
|
||||||
.split(area);
|
|
||||||
|
|
||||||
for i in 0..items {
|
for i in 0..items {
|
||||||
let DownloadRecord {
|
let DownloadRecord {
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ fn draw_seasons_table(f: &mut Frame<'_>, app: &mut App<'_>, area: Rect) {
|
|||||||
let row = Row::new(vec![
|
let row = Row::new(vec![
|
||||||
Cell::from(season_monitored.to_owned()),
|
Cell::from(season_monitored.to_owned()),
|
||||||
Cell::from(title.clone().unwrap()),
|
Cell::from(title.clone().unwrap()),
|
||||||
Cell::from(format!("{}/{}", episode_file_count, episode_count)),
|
Cell::from(format!("{episode_file_count}/{episode_count}")),
|
||||||
Cell::from(format!("{size:.2} GB")),
|
Cell::from(format!("{size:.2} GB")),
|
||||||
]);
|
]);
|
||||||
if !monitored {
|
if !monitored {
|
||||||
|
|||||||
+9
-10
@@ -106,9 +106,11 @@ fn draw_stats_context(f: &mut Frame<'_>, app: &App<'_>, area: Rect) {
|
|||||||
];
|
];
|
||||||
|
|
||||||
constraints.append(
|
constraints.append(
|
||||||
&mut iter::repeat(Constraint::Length(1))
|
&mut iter::repeat_n(
|
||||||
.take(disk_space_vec.len() + root_folders.items.len() + 1)
|
Constraint::Length(1),
|
||||||
.collect(),
|
disk_space_vec.len() + root_folders.items.len() + 1,
|
||||||
|
)
|
||||||
|
.collect(),
|
||||||
);
|
);
|
||||||
|
|
||||||
let stat_item_areas = Layout::vertical(constraints).margin(1).split(area);
|
let stat_item_areas = Layout::vertical(constraints).margin(1).split(area);
|
||||||
@@ -189,13 +191,10 @@ fn draw_downloads_context(f: &mut Frame<'_>, app: &App<'_>, area: Rect) {
|
|||||||
|
|
||||||
let max_items = ((((area.height as f64 / 2.0).floor() * 2.0) as i64) / 2) - 1;
|
let max_items = ((((area.height as f64 / 2.0).floor() * 2.0) as i64) / 2) - 1;
|
||||||
let items = cmp::min(downloads_vec.len(), max_items.unsigned_abs() as usize);
|
let items = cmp::min(downloads_vec.len(), max_items.unsigned_abs() as usize);
|
||||||
let download_item_areas = Layout::vertical(
|
let download_item_areas =
|
||||||
iter::repeat(Constraint::Length(2))
|
Layout::vertical(iter::repeat_n(Constraint::Length(2), items).collect::<Vec<Constraint>>())
|
||||||
.take(items)
|
.margin(1)
|
||||||
.collect::<Vec<Constraint>>(),
|
.split(area);
|
||||||
)
|
|
||||||
.margin(1)
|
|
||||||
.split(area);
|
|
||||||
|
|
||||||
for i in 0..items {
|
for i in 0..items {
|
||||||
let DownloadRecord {
|
let DownloadRecord {
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ impl ConfirmationPrompt<'_> {
|
|||||||
];
|
];
|
||||||
constraints.splice(
|
constraints.splice(
|
||||||
1..1,
|
1..1,
|
||||||
iter::repeat(Constraint::Length(3)).take(checkboxes.len()),
|
iter::repeat_n(Constraint::Length(3), checkboxes.len()),
|
||||||
);
|
);
|
||||||
let chunks = Layout::vertical(constraints).margin(1).split(area);
|
let chunks = Layout::vertical(constraints).margin(1).split(area);
|
||||||
let [yes_area, no_area] =
|
let [yes_area, no_area] =
|
||||||
|
|||||||
+9
-12
@@ -39,7 +39,7 @@ pub fn get_log_path() -> PathBuf {
|
|||||||
log_path.push("managarr");
|
log_path.push("managarr");
|
||||||
|
|
||||||
if let Err(e) = fs::create_dir_all(&log_path) {
|
if let Err(e) = fs::create_dir_all(&log_path) {
|
||||||
eprintln!("Failed to create log directory: {:?}", e);
|
eprintln!("Failed to create log directory: {e:?}");
|
||||||
}
|
}
|
||||||
|
|
||||||
log_path.push("managarr.log");
|
log_path.push("managarr.log");
|
||||||
@@ -96,10 +96,10 @@ pub async fn tail_logs(no_color: bool) {
|
|||||||
loop {
|
loop {
|
||||||
if let Some(Ok(line)) = lines.next() {
|
if let Some(Ok(line)) = lines.next() {
|
||||||
if no_color {
|
if no_color {
|
||||||
println!("{}", line);
|
println!("{line}");
|
||||||
} else {
|
} else {
|
||||||
let colored_line = colorize_log_line(&line, &re);
|
let colored_line = colorize_log_line(&line, &re);
|
||||||
println!("{}", colored_line);
|
println!("{colored_line}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -195,7 +195,7 @@ pub(super) fn build_network_client(config: &AppConfig) -> Client {
|
|||||||
match client_builder.build() {
|
match client_builder.build() {
|
||||||
Ok(client) => client,
|
Ok(client) => client,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Unable to create reqwest client: {}", e);
|
error!("Unable to create reqwest client: {e}");
|
||||||
eprintln!("error: {}", e.to_string().red());
|
eprintln!("error: {}", e.to_string().red());
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
@@ -208,16 +208,14 @@ pub(super) fn create_cert(cert_path: &String, servarr_name: &str) -> Certificate
|
|||||||
Ok(certificate) => certificate,
|
Ok(certificate) => certificate,
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
log_and_print_error(format!(
|
log_and_print_error(format!(
|
||||||
"Unable to read the specified {} SSL certificate",
|
"Unable to read the specified {servarr_name} SSL certificate"
|
||||||
servarr_name
|
|
||||||
));
|
));
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
log_and_print_error(format!(
|
log_and_print_error(format!(
|
||||||
"Unable to open specified {} SSL certificate",
|
"Unable to open specified {servarr_name} SSL certificate"
|
||||||
servarr_name
|
|
||||||
));
|
));
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
@@ -260,7 +258,7 @@ pub(super) async fn start_cli_with_spinner(
|
|||||||
match cli::handle_command(&app, command, &mut network).await {
|
match cli::handle_command(&app, command, &mut network).await {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
pb.finish();
|
pb.finish();
|
||||||
println!("{}", output);
|
println!("{output}");
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
pb.finish();
|
pb.finish();
|
||||||
@@ -287,7 +285,7 @@ pub(super) async fn start_cli_no_spinner(
|
|||||||
let mut network = Network::new(&app_nw, cancellation_token, reqwest_client);
|
let mut network = Network::new(&app_nw, cancellation_token, reqwest_client);
|
||||||
match cli::handle_command(&app, command, &mut network).await {
|
match cli::handle_command(&app, command, &mut network).await {
|
||||||
Ok(output) => {
|
Ok(output) => {
|
||||||
println!("{}", output);
|
println!("{output}");
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
eprintln!("error: {}", e.to_string().red());
|
eprintln!("error: {}", e.to_string().red());
|
||||||
@@ -306,8 +304,7 @@ pub fn select_cli_configuration(
|
|||||||
let trimmed_name = servarr_name.trim();
|
let trimmed_name = servarr_name.trim();
|
||||||
if !app.server_tabs.select_tab_by_title(trimmed_name) {
|
if !app.server_tabs.select_tab_by_title(trimmed_name) {
|
||||||
log_and_print_error(format!(
|
log_and_print_error(format!(
|
||||||
"A Servarr titled '{}' was not found in your configuration file",
|
"A Servarr titled '{trimmed_name}' was not found in your configuration file"
|
||||||
trimmed_name
|
|
||||||
));
|
));
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user