Address Clippy warnings
This commit is contained in:
parent
5028e16c5b
commit
3c4603dc7b
13 changed files with 38 additions and 36 deletions
|
|
@ -17,11 +17,11 @@ use crate::diags;
|
||||||
use core::{
|
use core::{
|
||||||
action::Action,
|
action::Action,
|
||||||
components::{
|
components::{
|
||||||
footer::Footer, fps::FpsCounter, left::Left, popup, right::Right, state::StatefulList,
|
Component, footer::Footer, fps::FpsCounter, left::Left, popup, right::Right,
|
||||||
title::Title, Component,
|
state::StatefulList, title::Title,
|
||||||
},
|
},
|
||||||
config::Config,
|
config::Config,
|
||||||
line::{get_disk_description_right, get_part_description, DVLine},
|
line::{DVLine, get_disk_description_right, get_part_description},
|
||||||
state::{CloneSettings, Mode},
|
state::{CloneSettings, Mode},
|
||||||
system::{
|
system::{
|
||||||
boot::{self, SafeMode},
|
boot::{self, SafeMode},
|
||||||
|
|
@ -894,7 +894,7 @@ fn build_right_items(app: &App) -> Action {
|
||||||
line_colors: vec![Color::Reset],
|
line_colors: vec![Color::Reset],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
header_lines.append(&mut get_disk_description_right(&disk, Some(parts)));
|
header_lines.append(&mut get_disk_description_right(disk, Some(parts)));
|
||||||
|
|
||||||
// Add header
|
// Add header
|
||||||
if !header_lines.is_empty() {
|
if !header_lines.is_empty() {
|
||||||
|
|
@ -957,10 +957,10 @@ fn build_right_items(app: &App) -> Action {
|
||||||
let disk_list = app.clone.disk_list.lock().unwrap();
|
let disk_list = app.clone.disk_list.lock().unwrap();
|
||||||
disk_list
|
disk_list
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|disk| items.push(get_disk_description_right(&disk, None)));
|
.for_each(|disk| items.push(get_disk_description_right(disk, None)));
|
||||||
}
|
}
|
||||||
Mode::SelectParts => {
|
Mode::SelectParts => {
|
||||||
vec!["Boot", "OS"].iter().for_each(|s| {
|
["Boot", "OS"].iter().for_each(|s| {
|
||||||
labels.push(vec![DVLine {
|
labels.push(vec![DVLine {
|
||||||
line_parts: vec![String::from(*s)],
|
line_parts: vec![String::from(*s)],
|
||||||
line_colors: vec![Color::Cyan],
|
line_colors: vec![Color::Cyan],
|
||||||
|
|
@ -971,12 +971,12 @@ fn build_right_items(app: &App) -> Action {
|
||||||
let disk_list = app.clone.disk_list.lock().unwrap();
|
let disk_list = app.clone.disk_list.lock().unwrap();
|
||||||
if let Some(disk) = disk_list.get(index) {
|
if let Some(disk) = disk_list.get(index) {
|
||||||
// Disk Details
|
// Disk Details
|
||||||
items.push(get_disk_description_right(&disk, None));
|
items.push(get_disk_description_right(disk, None));
|
||||||
|
|
||||||
// Partition Details
|
// Partition Details
|
||||||
disk.parts
|
disk.parts
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|part| items.push(get_part_description(&part)));
|
.for_each(|part| items.push(get_part_description(part)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
//
|
//
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use color_eyre::Result;
|
use color_eyre::Result;
|
||||||
use core;
|
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ impl Component for Footer {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
||||||
|
#[allow(clippy::single_match)]
|
||||||
match action {
|
match action {
|
||||||
Action::UpdateFooter(text) => self.text = text,
|
Action::UpdateFooter(text) => self.text = text,
|
||||||
_ => {}
|
_ => {}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ use ratatui::{
|
||||||
};
|
};
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
|
|
||||||
use super::{state::StatefulList, Component};
|
use super::{Component, state::StatefulList};
|
||||||
use crate::{action::Action, config::Config};
|
use crate::{action::Action, config::Config};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -167,7 +167,7 @@ impl Component for Left {
|
||||||
.map(|(index, item)| {
|
.map(|(index, item)| {
|
||||||
let mut style = Style::default();
|
let mut style = Style::default();
|
||||||
let text = if self.selections[0].is_some_and(|first_index| first_index == index) {
|
let text = if self.selections[0].is_some_and(|first_index| first_index == index) {
|
||||||
if let Some(label) = self.labels.get(0) {
|
if let Some(label) = self.labels.first() {
|
||||||
style = style.yellow();
|
style = style.yellow();
|
||||||
label.as_str()
|
label.as_str()
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ use ratatui::{
|
||||||
};
|
};
|
||||||
use tokio::sync::mpsc::UnboundedSender;
|
use tokio::sync::mpsc::UnboundedSender;
|
||||||
|
|
||||||
use super::{state::StatefulList, Component};
|
use super::{Component, state::StatefulList};
|
||||||
use crate::{action::Action, config::Config, line::DVLine};
|
use crate::{action::Action, config::Config, line::DVLine};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -150,7 +150,7 @@ impl Component for Right {
|
||||||
// First selection
|
// First selection
|
||||||
if let Some(first_index) = self.get_first() {
|
if let Some(first_index) = self.get_first() {
|
||||||
if let Some(first_desc) = self.list.get(first_index) {
|
if let Some(first_desc) = self.list.get(first_index) {
|
||||||
if let Some(label) = self.list_labels.get(0) {
|
if let Some(label) = self.list_labels.first() {
|
||||||
label
|
label
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|dv| body_text.push(dv.as_line().bold()));
|
.for_each(|dv| body_text.push(dv.as_line().bold()));
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,7 @@ impl Component for Title {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
fn update(&mut self, action: Action) -> Result<Option<Action>> {
|
||||||
|
#[allow(clippy::match_single_binding)]
|
||||||
match action {
|
match action {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ use derive_deref::{Deref, DerefMut};
|
||||||
use directories::ProjectDirs;
|
use directories::ProjectDirs;
|
||||||
use lazy_static::lazy_static;
|
use lazy_static::lazy_static;
|
||||||
use ratatui::style::{Color, Modifier, Style};
|
use ratatui::style::{Color, Modifier, Style};
|
||||||
use serde::{de::Deserializer, Deserialize};
|
use serde::{Deserialize, de::Deserializer};
|
||||||
use tracing::error;
|
use tracing::error;
|
||||||
|
|
||||||
use crate::{action::Action, state::Mode};
|
use crate::{action::Action, state::Mode};
|
||||||
|
|
@ -54,7 +54,7 @@ pub struct Config {
|
||||||
pub styles: Styles,
|
pub styles: Styles,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub static PROJECT_NAME: &'static str = "DEJA-VU";
|
pub static PROJECT_NAME: &str = "DEJA-VU";
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
//pub static ref PROJECT_NAME: String = env!("CARGO_PKG_NAME").to_uppercase().to_string();
|
//pub static ref PROJECT_NAME: String = env!("CARGO_PKG_NAME").to_uppercase().to_string();
|
||||||
pub static ref DATA_FOLDER: Option<PathBuf> =
|
pub static ref DATA_FOLDER: Option<PathBuf> =
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@ pub fn get_disk_description_right(
|
||||||
let mut line_parts = vec![line.clone()];
|
let mut line_parts = vec![line.clone()];
|
||||||
let mut line_colors = vec![Color::Reset];
|
let mut line_colors = vec![Color::Reset];
|
||||||
if let Some(indicies) = &boot_os_indicies {
|
if let Some(indicies) = &boot_os_indicies {
|
||||||
let boot_index = indicies.get(0);
|
let boot_index = indicies.first();
|
||||||
if boot_index.is_some_and(|i| i == &index) {
|
if boot_index.is_some_and(|i| i == &index) {
|
||||||
line_parts.push(String::from(" <-- Boot Partition"));
|
line_parts.push(String::from(" <-- Boot Partition"));
|
||||||
line_colors.push(Color::Cyan);
|
line_colors.push(Color::Cyan);
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ use std::{
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
process::{Command, Stdio},
|
process::{Command, Stdio},
|
||||||
sync::{Arc, Mutex},
|
sync::{Arc, Mutex},
|
||||||
thread::{self, sleep, JoinHandle},
|
thread::{self, JoinHandle, sleep},
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -180,7 +180,7 @@ impl Tasks {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
TaskType::Diskpart(ref script) => {
|
TaskType::Diskpart(ref script) => {
|
||||||
self.cur_handle = Some(run_task_diskpart(&script, task_tx));
|
self.cur_handle = Some(run_task_diskpart(script, task_tx));
|
||||||
}
|
}
|
||||||
TaskType::ScanDisks => {
|
TaskType::ScanDisks => {
|
||||||
let disk_list_arc = self.disk_list.clone();
|
let disk_list_arc = self.disk_list.clone();
|
||||||
|
|
@ -261,7 +261,9 @@ fn run_task_command(
|
||||||
let stdout = parse_bytes_as_str(output.stdout.to_owned());
|
let stdout = parse_bytes_as_str(output.stdout.to_owned());
|
||||||
let task_result = TaskResult::Output(stdout, stderr, output.status.success());
|
let task_result = TaskResult::Output(stdout, stderr, output.status.success());
|
||||||
let err_str = format!("Failed to send TaskResult: {:?}", &task_result);
|
let err_str = format!("Failed to send TaskResult: {:?}", &task_result);
|
||||||
task_tx.send(task_result).expect(err_str.as_str());
|
task_tx
|
||||||
|
.send(task_result)
|
||||||
|
.unwrap_or_else(|_| panic!("{}", err_str));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
@ -280,7 +282,9 @@ fn run_task_diskpart(script: &str, task_tx: mpsc::UnboundedSender<TaskResult>) -
|
||||||
let stdout = parse_bytes_as_str(output.stdout.to_owned());
|
let stdout = parse_bytes_as_str(output.stdout.to_owned());
|
||||||
let task_result = TaskResult::Output(stdout, stderr, output.status.success());
|
let task_result = TaskResult::Output(stdout, stderr, output.status.success());
|
||||||
let err_str = format!("Failed to send TaskResult: {:?}", &task_result);
|
let err_str = format!("Failed to send TaskResult: {:?}", &task_result);
|
||||||
task_tx.send(task_result).expect(err_str.as_str());
|
task_tx
|
||||||
|
.send(task_result)
|
||||||
|
.unwrap_or_else(|_| panic!("{}", err_str));
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// Simulate task if not running under Windows
|
// Simulate task if not running under Windows
|
||||||
|
|
|
||||||
|
|
@ -16,11 +16,11 @@
|
||||||
use core::{
|
use core::{
|
||||||
action::Action,
|
action::Action,
|
||||||
components::{
|
components::{
|
||||||
footer::Footer, fps::FpsCounter, left::Left, popup, right::Right, state::StatefulList,
|
Component, footer::Footer, fps::FpsCounter, left::Left, popup, right::Right,
|
||||||
title::Title, Component,
|
state::StatefulList, title::Title,
|
||||||
},
|
},
|
||||||
config::Config,
|
config::Config,
|
||||||
line::{get_disk_description_right, get_part_description, DVLine},
|
line::{DVLine, get_disk_description_right, get_part_description},
|
||||||
state::{CloneSettings, Mode},
|
state::{CloneSettings, Mode},
|
||||||
system::{
|
system::{
|
||||||
boot, cpu::get_cpu_name, disk::PartitionTableType, diskpart::build_dest_format_script,
|
boot, cpu::get_cpu_name, disk::PartitionTableType, diskpart::build_dest_format_script,
|
||||||
|
|
@ -100,7 +100,7 @@ impl App {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn prev_mode(&mut self) -> Option<Mode> {
|
pub fn prev_mode(&mut self) -> Option<Mode> {
|
||||||
let new_mode = match self.cur_mode {
|
match self.cur_mode {
|
||||||
Mode::Home => Some(Mode::Home),
|
Mode::Home => Some(Mode::Home),
|
||||||
Mode::Failed => Some(Mode::Failed),
|
Mode::Failed => Some(Mode::Failed),
|
||||||
Mode::Done => Some(Mode::Done),
|
Mode::Done => Some(Mode::Done),
|
||||||
|
|
@ -122,8 +122,7 @@ impl App {
|
||||||
| Mode::InjectDrivers
|
| Mode::InjectDrivers
|
||||||
| Mode::PEMenu
|
| Mode::PEMenu
|
||||||
| Mode::SetBootMode => panic!("This shouldn't happen?"),
|
| Mode::SetBootMode => panic!("This shouldn't happen?"),
|
||||||
};
|
}
|
||||||
new_mode
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn next_mode(&mut self) -> Option<Mode> {
|
pub fn next_mode(&mut self) -> Option<Mode> {
|
||||||
|
|
@ -770,10 +769,10 @@ fn build_right_items(app: &App, cur_mode: Mode) -> Action {
|
||||||
let disk_list = app.clone.disk_list.lock().unwrap();
|
let disk_list = app.clone.disk_list.lock().unwrap();
|
||||||
disk_list
|
disk_list
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|disk| items.push(get_disk_description_right(&disk, None)));
|
.for_each(|disk| items.push(get_disk_description_right(disk, None)));
|
||||||
}
|
}
|
||||||
Mode::SelectParts => {
|
Mode::SelectParts => {
|
||||||
vec!["Boot", "OS"].iter().for_each(|s| {
|
["Boot", "OS"].iter().for_each(|s| {
|
||||||
labels.push(vec![DVLine {
|
labels.push(vec![DVLine {
|
||||||
line_parts: vec![String::from(*s)],
|
line_parts: vec![String::from(*s)],
|
||||||
line_colors: vec![Color::Cyan],
|
line_colors: vec![Color::Cyan],
|
||||||
|
|
@ -784,12 +783,12 @@ fn build_right_items(app: &App, cur_mode: Mode) -> Action {
|
||||||
let disk_list = app.clone.disk_list.lock().unwrap();
|
let disk_list = app.clone.disk_list.lock().unwrap();
|
||||||
if let Some(disk) = disk_list.get(index) {
|
if let Some(disk) = disk_list.get(index) {
|
||||||
// Disk Details
|
// Disk Details
|
||||||
items.push(get_disk_description_right(&disk, None));
|
items.push(get_disk_description_right(disk, None));
|
||||||
|
|
||||||
// Partition Details
|
// Partition Details
|
||||||
disk.parts
|
disk.parts
|
||||||
.iter()
|
.iter()
|
||||||
.for_each(|part| items.push(get_part_description(&part)));
|
.for_each(|part| items.push(get_part_description(part)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
//
|
//
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use color_eyre::Result;
|
use color_eyre::Result;
|
||||||
use core;
|
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
use core::{
|
use core::{
|
||||||
action::Action,
|
action::Action,
|
||||||
components::{
|
components::{
|
||||||
footer::Footer, fps::FpsCounter, left::Left, popup, right::Right, state::StatefulList,
|
Component, footer::Footer, fps::FpsCounter, left::Left, popup, right::Right,
|
||||||
title::Title, Component,
|
state::StatefulList, title::Title,
|
||||||
},
|
},
|
||||||
config::Config,
|
config::Config,
|
||||||
line::DVLine,
|
line::DVLine,
|
||||||
|
|
@ -230,7 +230,7 @@ impl App {
|
||||||
// Run selected tool
|
// Run selected tool
|
||||||
if let Some(tool) = self.list.get_selected() {
|
if let Some(tool) = self.list.get_selected() {
|
||||||
info!("Run tool: {:?}", &tool);
|
info!("Run tool: {:?}", &tool);
|
||||||
self.tasks.add(build_tool_command(&self, &tool));
|
self.tasks.add(build_tool_command(self, &tool));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Action::Resize(w, h) => self.handle_resize(tui, w, h)?,
|
Action::Resize(w, h) => self.handle_resize(tui, w, h)?,
|
||||||
|
|
@ -453,7 +453,7 @@ pub fn load_tools() -> Vec<Tool> {
|
||||||
entries
|
entries
|
||||||
.iter()
|
.iter()
|
||||||
.map(|entry| {
|
.map(|entry| {
|
||||||
let contents = fs::read_to_string(&entry).expect("Failed to read tool config file");
|
let contents = fs::read_to_string(entry).expect("Failed to read tool config file");
|
||||||
let tool: Tool = toml::from_str(&contents).expect("Failed to parse tool config file");
|
let tool: Tool = toml::from_str(&contents).expect("Failed to parse tool config file");
|
||||||
tool
|
tool
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,6 @@
|
||||||
//
|
//
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use color_eyre::Result;
|
use color_eyre::Result;
|
||||||
use core;
|
|
||||||
|
|
||||||
use crate::app::App;
|
use crate::app::App;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue