From d200d13c26d7f4a0d1eae75e77beaeab4859a8ce Mon Sep 17 00:00:00 2001 From: Jack Wills <32690432+mrjackwills@users.noreply.github.com> Date: Sun, 19 Nov 2023 22:48:49 +0000 Subject: [PATCH] refactor: dead code removed --- src/exec.rs | 7 ------- src/input_handler/mod.rs | 9 +-------- src/ui/draw_blocks.rs | 2 +- src/ui/mod.rs | 9 ++------- 4 files changed, 4 insertions(+), 23 deletions(-) diff --git a/src/exec.rs b/src/exec.rs index 6a36d94..7092505 100644 --- a/src/exec.rs +++ b/src/exec.rs @@ -1,12 +1,9 @@ use std::{ - fmt, - hash::{Hash, Hasher}, io::{Read, Write}, sync::{atomic::AtomicBool, Arc}, }; use bollard::{ - container, exec::{CreateExecOptions, StartExecOptions, StartExecResults}, Docker, }; @@ -18,8 +15,6 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt}; use crate::{ app_data::{AppData, ContainerId, State}, app_error::AppError, - parse_args::CliArgs, - ui::{GuiState, Status}, }; /// TTY location @@ -304,8 +299,6 @@ impl ExecMode { // RESET TERMINAL BEFROEHAND pub async fn run( &self, - app_data: &Arc>, - gui_state: &Arc>, ) -> Result<(), AppError> { match self { Self::External(id) => { diff --git a/src/input_handler/mod.rs b/src/input_handler/mod.rs index 6c7e52d..4d19829 100644 --- a/src/input_handler/mod.rs +++ b/src/input_handler/mod.rs @@ -1,7 +1,6 @@ use std::{ fs::OpenOptions, io::{BufWriter, Write}, - path::Path, sync::{ atomic::{AtomicBool, Ordering}, Arc, @@ -18,10 +17,7 @@ use crossterm::{ use futures_util::StreamExt; use parking_lot::Mutex; use ratatui::layout::Rect; -use tokio::{ - sync::mpsc::{Receiver, Sender}, - task::JoinHandle, -}; +use tokio::sync::mpsc::{Receiver, Sender}; use uuid::Uuid; mod message; @@ -40,7 +36,6 @@ pub struct InputHandler { app_data: Arc>, docker_sender: Sender, gui_state: Arc>, - info_sleep: Option>, is_running: Arc, mouse_capture: bool, rec: Receiver, @@ -62,7 +57,6 @@ impl InputHandler { is_running, rec, mouse_capture: true, - info_sleep: None, }; inner.start().await; } @@ -132,7 +126,6 @@ impl InputHandler { /// Validate that one can exec into a Docker container async fn e_key(&self) { let is_oxker = self.app_data.lock().is_oxker(); - let mut exec_err = Some(()); if !is_oxker && tty_readable() { let uuid = Uuid::new_v4(); let handle = GuiState::start_loading_animation(&self.gui_state, uuid); diff --git a/src/ui/draw_blocks.rs b/src/ui/draw_blocks.rs index 5008d3c..6658105 100644 --- a/src/ui/draw_blocks.rs +++ b/src/ui/draw_blocks.rs @@ -20,7 +20,7 @@ use crate::{ }; use super::{ - gui_state::{self, BoxLocation, DeleteButton, Region}, + gui_state::{BoxLocation, DeleteButton, Region}, FrameData, }; use super::{GuiState, SelectablePanel}; diff --git a/src/ui/mod.rs b/src/ui/mod.rs index d5aeac5..e49c435 100644 --- a/src/ui/mod.rs +++ b/src/ui/mod.rs @@ -1,5 +1,4 @@ use anyhow::Result; -use bollard::Docker; use crossterm::{ event::{self, DisableMouseCapture, Event}, execute, @@ -29,13 +28,11 @@ pub use self::gui_state::{DeleteButton, GuiState, SelectablePanel, Status}; use crate::{ app_data::{AppData, Columns, ContainerId, Header, SortedOrder}, app_error::AppError, - docker_data::DockerMessage, input_handler::InputMessages, }; pub struct Ui { app_data: Arc>, - docker_sx: Sender, gui_state: Arc>, input_poll_rate: Duration, is_running: Arc, @@ -61,7 +58,6 @@ impl Ui { /// Create a new Ui struct, and execute the drawing loop pub async fn create( app_data: Arc>, - docker_sx: Sender, gui_state: Arc>, is_running: Arc, sender: Sender, @@ -71,7 +67,6 @@ impl Ui { let cursor_position = terminal.get_cursor().unwrap_or_default(); let mut ui = Self { app_data, - docker_sx, gui_state, input_poll_rate: std::time::Duration::from_millis(100), is_running, @@ -147,12 +142,12 @@ impl Ui { /// Use exeternal docker cli to exec into a container async fn exec(&mut self) { - let mut exec_mode = self.gui_state.lock().get_exec_mode(); + let exec_mode = self.gui_state.lock().get_exec_mode(); if let Some(mode) = exec_mode { self.reset_terminal().ok(); self.terminal.clear().ok(); - if let Err(e) = mode.run(&self.app_data, &self.gui_state).await { + if let Err(e) = mode.run().await { self.app_data .lock() .set_error(e, &self.gui_state, Status::Error);