cleaned up with clippy

This commit is contained in:
Penwing 2024-01-25 20:51:56 +01:00
parent c8ce57781e
commit 89dafdf022
11 changed files with 84 additions and 90 deletions

View file

@ -69,7 +69,7 @@ impl Calcifer {
return; return;
} }
egui::TopBottomPanel::bottom("terminal") egui::TopBottomPanel::bottom("terminal")
.default_height(super::TERMINAL_HEIGHT.clone()) .default_height(super::TERMINAL_HEIGHT)
.height_range(Rangef::new( .height_range(Rangef::new(
super::TERMINAL_RANGE.start, super::TERMINAL_RANGE.start,
super::TERMINAL_RANGE.end, super::TERMINAL_RANGE.end,
@ -93,7 +93,7 @@ impl Calcifer {
ui.style_mut().visuals.extreme_bg_color = bg_color; ui.style_mut().visuals.extreme_bg_color = bg_color;
let Self { command, .. } = self; let Self { command, .. } = self;
ui.colored_label( ui.colored_label(
command_color.clone(), command_color,
tools::format_path( tools::format_path(
&env::current_dir().expect("Could not find Shell Environnment"), &env::current_dir().expect("Could not find Shell Environnment"),
), ),
@ -126,11 +126,11 @@ impl Calcifer {
format!("\n{} {}", entry.env, entry.command), format!("\n{} {}", entry.env, entry.command),
); );
ui.end_row(); ui.end_row();
if entry.output != "" { if !entry.output.is_empty() {
ui.colored_label(entry_color, &entry.output); ui.colored_label(entry_color, &entry.output);
ui.end_row(); ui.end_row();
} }
if entry.error != "" { if !entry.error.is_empty() {
ui.colored_label(super::RED, &entry.error); ui.colored_label(super::RED, &entry.error);
ui.end_row(); ui.end_row();
} }
@ -277,7 +277,7 @@ impl Calcifer {
self.settings_menu.show(ctx); self.settings_menu.show(ctx);
} }
if self.settings_menu.updated { if self.settings_menu.updated {
self.theme = self.settings_menu.theme.clone(); self.theme = self.settings_menu.theme;
} }
self.handle_confirm(); self.handle_confirm();

View file

@ -29,10 +29,9 @@ impl Calcifer {
.file_name() .file_name()
.expect("Could not get Tab Name") .expect("Could not get Tab Name")
.to_string_lossy() .to_string_lossy()
.to_string()
== "untitled" == "untitled"
{ {
return self.save_tab_as(); self.save_tab_as()
} else { } else {
if let Err(err) = fs::write( if let Err(err) = fs::write(
&self.tabs[self.selected_tab.to_index()].path, &self.tabs[self.selected_tab.to_index()].path,
@ -41,7 +40,7 @@ impl Calcifer {
eprintln!("Error writing file: {}", err); eprintln!("Error writing file: {}", err);
return None; return None;
} }
return Some(self.tabs[self.selected_tab.to_index()].path.clone()); Some(self.tabs[self.selected_tab.to_index()].path.clone())
} }
} }
@ -56,7 +55,7 @@ impl Calcifer {
} }
return Some(path); return Some(path);
} }
return None; None
} }
pub fn handle_save_file(&mut self, path_option: Option<PathBuf>) { pub fn handle_save_file(&mut self, path_option: Option<PathBuf>) {
@ -82,7 +81,6 @@ impl Calcifer {
.file_name() .file_name()
.expect("Could not get Tab Name") .expect("Could not get Tab Name")
.to_string_lossy() .to_string_lossy()
.to_string()
!= "untitled" != "untitled"
{ {
new.open_file(Some(&path)); new.open_file(Some(&path));
@ -131,21 +129,19 @@ impl Calcifer {
if let Some(name) = path.file_name() { if let Some(name) = path.file_name() {
if path.is_dir() { if path.is_dir() {
egui::CollapsingHeader::new(name.to_string_lossy()).show(ui, |ui| { egui::CollapsingHeader::new(name.to_string_lossy()).show(ui, |ui| {
let mut paths: Vec<_> = fs::read_dir(&path) let mut paths: Vec<_> = fs::read_dir(path)
.expect("Failed to read dir") .expect("Failed to read dir")
.map(|r| r.unwrap()) .map(|r| r.unwrap())
.collect(); .collect();
paths.sort_by(|a, b| tools::sort_directories_first(a, b)); paths.sort_by(tools::sort_directories_first);
for result in paths { for result in paths {
let _ = self.list_files(ui, &result.path()); let _ = self.list_files(ui, &result.path());
} }
}); });
} else { } else if ui.button(name.to_string_lossy()).clicked() {
if ui.button(name.to_string_lossy()).clicked() { self.open_file(Some(path));
self.open_file(Some(path));
}
} }
} }
Ok(()) Ok(())
@ -171,7 +167,7 @@ impl Calcifer {
let bg_color: Color32; let bg_color: Color32;
let text_color: Color32; let text_color: Color32;
if display.clone() { if display {
bg_color = Color32::from_hex(self.theme.functions) bg_color = Color32::from_hex(self.theme.functions)
.expect("Could not convert color to hex (functions)"); .expect("Could not convert color to hex (functions)");
text_color = text_color =
@ -190,7 +186,7 @@ impl Calcifer {
} }
ui.style_mut().visuals.override_text_color = None; ui.style_mut().visuals.override_text_color = None;
return display; display
} }
pub fn profiler(&self) -> String { pub fn profiler(&self) -> String {
@ -199,7 +195,7 @@ impl Calcifer {
} }
let combined_string: Vec<String> = TIME_LABELS let combined_string: Vec<String> = TIME_LABELS
.into_iter() .into_iter()
.zip(self.time_watch.clone().into_iter()) .zip(self.time_watch.clone())
.map(|(s, v)| format!("{} : {:.1} ms", s, v)) .map(|(s, v)| format!("{} : {:.1} ms", s, v))
.collect(); .collect();
@ -208,6 +204,6 @@ impl Calcifer {
" total : {:.1} ms", " total : {:.1} ms",
self.time_watch.clone().iter().sum::<f32>() self.time_watch.clone().iter().sum::<f32>()
)); ));
return result; result
} }
} }

View file

@ -283,7 +283,7 @@ impl CodeEditor {
&& ui.input(|i| i.key_pressed(egui::Key::Enter)) && ui.input(|i| i.key_pressed(egui::Key::Enter))
{ {
if let Some(range) = last_cursor { if let Some(range) = last_cursor {
(*text, extend) = self.new_line(range.clone(), text.clone()); (*text, extend) = self.new_line(*range, text.clone());
get_new_cursor = false; get_new_cursor = false;
} }
} }
@ -293,7 +293,7 @@ impl CodeEditor {
{ {
if let Some(range) = last_cursor { if let Some(range) = last_cursor {
(*text, extend) = (*text, extend) =
self.toggle_start_of_line(range.clone(), text.clone(), "//"); self.toggle_start_of_line(*range, text.clone(), "//");
get_new_cursor = false; get_new_cursor = false;
} }
} }
@ -304,7 +304,7 @@ impl CodeEditor {
if let Some(range) = last_cursor { if let Some(range) = last_cursor {
if range.primary.index != range.secondary.index { if range.primary.index != range.secondary.index {
(*text, extend) = self.add_start_of_line( (*text, extend) = self.add_start_of_line(
range.clone(), *range,
previous_text.clone(), previous_text.clone(),
"\t", "\t",
); );
@ -319,7 +319,7 @@ impl CodeEditor {
if let Some(range) = last_cursor { if let Some(range) = last_cursor {
if range.primary.index != range.secondary.index { if range.primary.index != range.secondary.index {
(*text, extend) = self.remove_start_of_line( (*text, extend) = self.remove_start_of_line(
range.clone(), *range,
previous_text.clone(), previous_text.clone(),
"\t", "\t",
); );
@ -328,34 +328,32 @@ impl CodeEditor {
} }
} }
if override_cursor != None { if override_cursor.is_some() {
output.response.request_focus(); output.response.request_focus();
output.state.set_ccursor_range(override_cursor); output.state.set_ccursor_range(override_cursor);
output.state.store(ui.ctx(), output.response.id); output.state.store(ui.ctx(), output.response.id);
} else if get_new_cursor { } else if get_new_cursor {
*last_cursor = output.state.clone().ccursor_range(); *last_cursor = output.state.clone().ccursor_range();
} else { } else if let Some(cursor_range) = *last_cursor {
if let Some(cursor_range) = last_cursor.clone() { let mut start =
let mut start = min(cursor_range.primary.index, cursor_range.secondary.index);
min(cursor_range.primary.index, cursor_range.secondary.index); let end =
let end = max(cursor_range.primary.index, cursor_range.secondary.index);
max(cursor_range.primary.index, cursor_range.secondary.index); let extended = match end as isize + extend {
let extended = match end as isize + extend { // Check for overflow or negative result
// Check for overflow or negative result value if value < 0 => 0,
value if value < 0 => 0, value => value as usize,
value => value as usize, };
}; if start == end {
if start == end { start = extended;
start = extended;
}
let cursor = Some(CCursorRange {
primary: CCursor::new(start.clone()),
secondary: CCursor::new(max(start.clone(), extended)),
});
output.state.set_ccursor_range(cursor.clone());
output.state.store(ui.ctx(), output.response.id);
*last_cursor = cursor.clone();
} }
let cursor = Some(CCursorRange {
primary: CCursor::new(start),
secondary: CCursor::new(max(start, extended)),
});
output.state.set_ccursor_range(cursor);
output.state.store(ui.ctx(), output.response.id);
*last_cursor = cursor;
} }
if previous_text != text.clone() { if previous_text != text.clone() {
@ -369,9 +367,9 @@ impl CodeEditor {
let scroll_area = egui::ScrollArea::vertical() let scroll_area = egui::ScrollArea::vertical()
.id_source(format!("{}_outer_scroll", self.id)) .id_source(format!("{}_outer_scroll", self.id))
.stick_to_bottom(self.stick_to_bottom) .stick_to_bottom(self.stick_to_bottom)
.vertical_scroll_offset(vertical_offset.clone()) .vertical_scroll_offset(*vertical_offset)
.show(ui, code_editor); .show(ui, code_editor);
*vertical_offset = scroll_area.state.offset.y.clone(); *vertical_offset = scroll_area.state.offset.y;
} else { } else {
code_editor(ui); code_editor(ui);
} }
@ -386,14 +384,14 @@ impl CodeEditor {
head: &str, head: &str,
) -> (String, isize) { ) -> (String, isize) {
let mut substring = self let mut substring = self
.get_selection_substring(text.clone(), cursor_range.clone()) .get_selection_substring(text.clone(), cursor_range)
.clone(); .clone();
let mut new_text: String = "".into(); let mut new_text: String = "".into();
let extend: isize; let extend: isize;
if substring[1].contains(head) { if substring[1].contains(head) {
extend = -self.delta_char(substring[1].clone(), head); extend = -self.delta_char(substring[1].clone(), head);
substring[1] = substring[1].replace(&format!("\n{}", head), &"\n".to_string()); substring[1] = substring[1].replace(&format!("\n{}", head), "\n");
} else { } else {
extend = self.delta_char(substring[1].clone(), head); extend = self.delta_char(substring[1].clone(), head);
substring[1] = substring[1].replace(&"\n".to_string(), &format!("\n{}", head)); substring[1] = substring[1].replace(&"\n".to_string(), &format!("\n{}", head));
@ -402,7 +400,7 @@ impl CodeEditor {
new_text.push_str(&substring[1].clone()); new_text.push_str(&substring[1].clone());
new_text.push_str(&substring[2].clone()); new_text.push_str(&substring[2].clone());
return (new_text, extend); (new_text, extend)
} }
fn add_start_of_line( fn add_start_of_line(
@ -412,7 +410,7 @@ impl CodeEditor {
head: &str, head: &str,
) -> (String, isize) { ) -> (String, isize) {
let mut substring = self let mut substring = self
.get_selection_substring(text.clone(), cursor_range.clone()) .get_selection_substring(text.clone(), cursor_range)
.clone(); .clone();
let mut new_text: String = "".into(); let mut new_text: String = "".into();
@ -423,7 +421,7 @@ impl CodeEditor {
new_text.push_str(&substring[1].clone()); new_text.push_str(&substring[1].clone());
new_text.push_str(&substring[2].clone()); new_text.push_str(&substring[2].clone());
return (new_text, extend); (new_text, extend)
} }
fn remove_start_of_line( fn remove_start_of_line(
@ -433,18 +431,18 @@ impl CodeEditor {
head: &str, head: &str,
) -> (String, isize) { ) -> (String, isize) {
let mut substring = self let mut substring = self
.get_selection_substring(text.clone(), cursor_range.clone()) .get_selection_substring(text.clone(), cursor_range)
.clone(); .clone();
let mut new_text: String = "".into(); let mut new_text: String = "".into();
let extend: isize = -self.delta_char(substring[1].clone(), head); let extend: isize = -self.delta_char(substring[1].clone(), head);
substring[1] = substring[1].replace(&format!("\n{}", head), &"\n".to_string()); substring[1] = substring[1].replace(&format!("\n{}", head), "\n");
new_text.push_str(&substring[0].clone()); new_text.push_str(&substring[0].clone());
new_text.push_str(&substring[1].clone()); new_text.push_str(&substring[1].clone());
new_text.push_str(&substring[2].clone()); new_text.push_str(&substring[2].clone());
return (new_text, extend); (new_text, extend)
} }
fn get_selection_substring(&self, text: String, cursor_range: CCursorRange) -> Vec<String> { fn get_selection_substring(&self, text: String, cursor_range: CCursorRange) -> Vec<String> {
@ -459,11 +457,11 @@ impl CodeEditor {
let last_char = end; let last_char = end;
return vec![ vec![
text.slice(..first_char).to_string(), text.slice(..first_char).to_string(),
text.slice(first_char..last_char).to_string(), text.slice(first_char..last_char).to_string(),
text.slice(last_char..).to_string(), text.slice(last_char..).to_string(),
]; ]
} }
fn delta_char(&self, text: String, modifier: &str) -> isize { fn delta_char(&self, text: String, modifier: &str) -> isize {
@ -478,7 +476,7 @@ impl CodeEditor {
let cursor = min(cursor_range.primary.index, cursor_range.secondary.index); let cursor = min(cursor_range.primary.index, cursor_range.secondary.index);
if cursor < 2 { if cursor < 2 {
return (text.clone().to_string(), 1 as isize); return (text.clone().to_string(), 1_isize);
} }
let mut last_line_break = cursor - 1; let mut last_line_break = cursor - 1;
@ -492,15 +490,15 @@ impl CodeEditor {
.collect::<Vec<_>>() .collect::<Vec<_>>()
.len(); .len();
let new_indent_depth = indent_depth.clone(); let new_indent_depth = indent_depth;
let mut new_text: String = text.clone().slice(..(cursor + 1)).to_string(); let mut new_text: String = text.clone().slice(..(cursor + 1)).to_string();
new_text.push_str(&"\t".repeat(new_indent_depth.clone())); new_text.push_str(&"\t".repeat(new_indent_depth));
new_text.push_str(text.clone().slice((cursor + 1)..)); new_text.push_str(text.clone().slice((cursor + 1)..));
return ( (
new_text.clone().to_string(), new_text.clone().to_string(),
(new_indent_depth + 1) as isize, (new_indent_depth + 1) as isize,
); )
} }
} }

View file

@ -182,8 +182,8 @@ impl eframe::App for Calcifer {
} }
if ctx.input(|i| i.key_pressed(egui::Key::F) && i.modifiers.ctrl) { if ctx.input(|i| i.key_pressed(egui::Key::F) && i.modifiers.ctrl) {
self.search_menu.visible = !self.search_menu.visible.clone(); self.search_menu.visible = !self.search_menu.visible;
self.search_menu.initialized = !self.search_menu.visible.clone(); self.search_menu.initialized = !self.search_menu.visible;
} }
if ctx.input(|i| i.viewport().close_requested()) { if ctx.input(|i| i.viewport().close_requested()) {
@ -193,7 +193,7 @@ impl eframe::App for Calcifer {
unsaved_tabs.push(index); unsaved_tabs.push(index);
} }
} }
if unsaved_tabs.len() > 0 { if !unsaved_tabs.is_empty() {
let mut unsaved_tabs_names: String = "".to_string(); let mut unsaved_tabs_names: String = "".to_string();
for index in unsaved_tabs.iter() { for index in unsaved_tabs.iter() {
unsaved_tabs_names.push_str(&self.tabs[*index].get_name()); unsaved_tabs_names.push_str(&self.tabs[*index].get_name());

View file

@ -18,13 +18,13 @@ impl ConfirmWindow {
} }
pub fn show(&mut self, ctx: &egui::Context) { pub fn show(&mut self, ctx: &egui::Context) {
let mut visible = self.visible.clone(); let mut visible = self.visible;
egui::Window::new(self.id.clone()) egui::Window::new(self.id.clone())
.open(&mut visible) .open(&mut visible)
.vscroll(true) .vscroll(true)
.hscroll(true) .hscroll(true)
.show(ctx, |ui| self.ui(ui)); .show(ctx, |ui| self.ui(ui));
self.visible = self.visible.clone() && visible; self.visible = self.visible && visible;
} }
fn ui(&mut self, ui: &mut egui::Ui) { fn ui(&mut self, ui: &mut egui::Ui) {

View file

@ -134,7 +134,7 @@ pub fn version() -> String {
} }
} }
} }
return "".to_string(); "".to_string()
} }
#[cfg(test)] #[cfg(test)]

View file

@ -73,13 +73,13 @@ impl Default for SearchWindow {
impl SearchWindow { impl SearchWindow {
pub fn show(&mut self, ctx: &egui::Context, tabs: &mut Vec<Tab>, selected_tab: &mut TabNumber) { pub fn show(&mut self, ctx: &egui::Context, tabs: &mut Vec<Tab>, selected_tab: &mut TabNumber) {
let mut visible = self.visible.clone(); let mut visible = self.visible;
egui::Window::new("Search") egui::Window::new("Search")
.open(&mut visible) //I want it to be able to change its visibility (if user close manually) .open(&mut visible) //I want it to be able to change its visibility (if user close manually)
.vscroll(true) .vscroll(true)
.hscroll(true) .hscroll(true)
.show(ctx, |ui| self.ui(ui, tabs, selected_tab)); //but I want to edit the rest of the parameters and maybe close automatically .show(ctx, |ui| self.ui(ui, tabs, selected_tab)); //but I want to edit the rest of the parameters and maybe close automatically
self.visible = self.visible.clone() && visible; self.visible = self.visible && visible;
} }
fn ui(&mut self, ui: &mut egui::Ui, tabs: &mut Vec<Tab>, selected_tab: &mut TabNumber) { fn ui(&mut self, ui: &mut egui::Ui, tabs: &mut Vec<Tab>, selected_tab: &mut TabNumber) {
@ -115,8 +115,8 @@ impl SearchWindow {
} }
if self.search_text == self.searched_text if self.search_text == self.searched_text
&& self.search_text.len() > 0 && !self.search_text.is_empty()
&& self.results.len() == 0 && self.results.is_empty()
{ {
ui.colored_label(RED, " 0/0 "); ui.colored_label(RED, " 0/0 ");
} else { } else {
@ -132,7 +132,7 @@ impl SearchWindow {
} }
}); });
let previous_bool_state = self.across_documents.clone(); let previous_bool_state = self.across_documents;
ui.checkbox(&mut self.across_documents, "Across documents"); ui.checkbox(&mut self.across_documents, "Across documents");
if previous_bool_state != self.across_documents { if previous_bool_state != self.across_documents {
self.searched_text = "".into(); self.searched_text = "".into();
@ -164,15 +164,15 @@ impl SearchWindow {
} }
pub fn get_cursor_start(&self) -> usize { pub fn get_cursor_start(&self) -> usize {
self.results[self.current_result].start.clone() self.results[self.current_result].start
} }
pub fn get_cursor_end(&self) -> usize { pub fn get_cursor_end(&self) -> usize {
self.results[self.current_result].end.clone() self.results[self.current_result].end
} }
fn search(&mut self, tabs: &mut Vec<Tab>, selected_tab: &mut TabNumber) { fn search(&mut self, tabs: &mut Vec<Tab>, selected_tab: &mut TabNumber) {
if self.search_text.len() == 0 { if self.search_text.is_empty() {
return; return;
} }
@ -194,7 +194,7 @@ impl SearchWindow {
self.results = search_results.clone(); self.results = search_results.clone();
self.current_result = 0; self.current_result = 0;
if self.results.len() > 0 { if !self.results.is_empty() {
self.find_result(tabs, selected_tab, 0); self.find_result(tabs, selected_tab, 0);
} }
} }
@ -215,7 +215,7 @@ impl SearchWindow {
fn find_result(&mut self, tabs: &mut Vec<Tab>, selected_tab: &mut TabNumber, direction: i32) { fn find_result(&mut self, tabs: &mut Vec<Tab>, selected_tab: &mut TabNumber, direction: i32) {
if self.searched_text != self.search_text { if self.searched_text != self.search_text {
self.search(tabs, &mut *selected_tab); self.search(tabs, &mut *selected_tab);
} else if self.results.len() > 0 { } else if !self.results.is_empty() {
self.current_result = self.current_result =
(self.current_result as i32 + direction + self.results.len() as i32) as usize (self.current_result as i32 + direction + self.results.len() as i32) as usize
% self.results.len(); % self.results.len();

View file

@ -18,13 +18,13 @@ impl SettingsWindow {
} }
pub fn show(&mut self, ctx: &egui::Context) { pub fn show(&mut self, ctx: &egui::Context) {
let mut visible = self.visible.clone(); let mut visible = self.visible;
egui::Window::new("Settings") egui::Window::new("Settings")
.open(&mut visible) //I want it to be able to change its visibility (if user close manually) .open(&mut visible) //I want it to be able to change its visibility (if user close manually)
.vscroll(true) .vscroll(true)
.hscroll(true) .hscroll(true)
.show(ctx, |ui| self.ui(ui)); //but I want to edit the rest of the parameters and maybe close automatically .show(ctx, |ui| self.ui(ui)); //but I want to edit the rest of the parameters and maybe close automatically
self.visible = self.visible.clone() && visible; self.visible = self.visible && visible;
} }
fn ui(&mut self, ui: &mut egui::Ui) { fn ui(&mut self, ui: &mut egui::Ui) {
@ -32,9 +32,9 @@ impl SettingsWindow {
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.label("Theme "); ui.label("Theme ");
let previous_theme = self.theme.clone(); let previous_theme = self.theme;
egui::ComboBox::from_label("") egui::ComboBox::from_label("")
.selected_text(format!("{}", self.theme.name)) .selected_text(self.theme.name.to_string())
.show_ui(ui, |ui| { .show_ui(ui, |ui| {
ui.style_mut().wrap = Some(false); ui.style_mut().wrap = Some(false);
ui.set_min_width(60.0); ui.set_min_width(60.0);

View file

@ -10,13 +10,13 @@ impl ShortcutsWindow {
} }
pub fn show(&mut self, ctx: &egui::Context) { pub fn show(&mut self, ctx: &egui::Context) {
let mut visible = self.visible.clone(); let mut visible = self.visible;
egui::Window::new("Shortcuts") egui::Window::new("Shortcuts")
.open(&mut visible) .open(&mut visible)
.vscroll(true) .vscroll(true)
.hscroll(true) .hscroll(true)
.show(ctx, |ui| self.ui(ui)); .show(ctx, |ui| self.ui(ui));
self.visible = self.visible.clone() && visible; self.visible = self.visible && visible;
} }
fn ui(&mut self, ui: &mut egui::Ui) { fn ui(&mut self, ui: &mut egui::Ui) {

View file

@ -51,7 +51,7 @@ impl Default for Tab {
impl Tab { impl Tab {
pub fn new(path: PathBuf) -> Self { pub fn new(path: PathBuf) -> Self {
Self { Self {
path: path.clone().into(), path: path.clone(),
code: read_to_string(path.clone()) code: read_to_string(path.clone())
.expect("Not able to read the file") .expect("Not able to read the file")
.replace(&" ".repeat(4), "\t"), .replace(&" ".repeat(4), "\t"),

View file

@ -64,7 +64,7 @@ pub fn send_command(command: String) -> CommandEntry {
return entry; return entry;
} }
let path_append = command[3..].replace("~", "/home/penwing"); let path_append = command[3..].replace('~', "/home/penwing");
let path = Path::new(&path_append); let path = Path::new(&path_append);
if format!("{}", path.display()) == "/" { if format!("{}", path.display()) == "/" {
@ -76,12 +76,12 @@ pub fn send_command(command: String) -> CommandEntry {
if env::set_current_dir(path).is_ok() { if env::set_current_dir(path).is_ok() {
let mut entry = CommandEntry::new(format!("echo Moved to : {}", path.display())); let mut entry = CommandEntry::new(format!("echo Moved to : {}", path.display()));
entry.command = command; entry.command = command;
return entry; entry
} else { } else {
let mut entry = let mut entry =
CommandEntry::new(format!("echo Could not find path : {} >&2", path.display())); CommandEntry::new(format!("echo Could not find path : {} >&2", path.display()));
entry.command = command; entry.command = command;
return entry; entry
} }
} }
@ -110,5 +110,5 @@ pub fn execute(
fcntl(stderr_fd, FcntlArg::F_SETFL(OFlag::O_NONBLOCK)) fcntl(stderr_fd, FcntlArg::F_SETFL(OFlag::O_NONBLOCK))
.expect("Failed to set non-blocking mode"); .expect("Failed to set non-blocking mode");
return (BufReader::new(stdout), BufReader::new(stderr)); (BufReader::new(stdout), BufReader::new(stderr))
} }