refactor: dead code removed

This commit is contained in:
Jack Wills
2023-11-19 22:48:49 +00:00
parent 2de76e2f35
commit d200d13c26
4 changed files with 4 additions and 23 deletions
-7
View File
@@ -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<Mutex<AppData>>,
gui_state: &Arc<Mutex<GuiState>>,
) -> Result<(), AppError> {
match self {
Self::External(id) => {
+1 -8
View File
@@ -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<Mutex<AppData>>,
docker_sender: Sender<DockerMessage>,
gui_state: Arc<Mutex<GuiState>>,
info_sleep: Option<JoinHandle<()>>,
is_running: Arc<AtomicBool>,
mouse_capture: bool,
rec: Receiver<InputMessages>,
@@ -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);
+1 -1
View File
@@ -20,7 +20,7 @@ use crate::{
};
use super::{
gui_state::{self, BoxLocation, DeleteButton, Region},
gui_state::{BoxLocation, DeleteButton, Region},
FrameData,
};
use super::{GuiState, SelectablePanel};
+2 -7
View File
@@ -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<Mutex<AppData>>,
docker_sx: Sender<DockerMessage>,
gui_state: Arc<Mutex<GuiState>>,
input_poll_rate: Duration,
is_running: Arc<AtomicBool>,
@@ -61,7 +58,6 @@ impl Ui {
/// Create a new Ui struct, and execute the drawing loop
pub async fn create(
app_data: Arc<Mutex<AppData>>,
docker_sx: Sender<DockerMessage>,
gui_state: Arc<Mutex<GuiState>>,
is_running: Arc<AtomicBool>,
sender: Sender<InputMessages>,
@@ -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);