refactor: dead code removed
This commit is contained in:
@@ -1,12 +1,9 @@
|
|||||||
use std::{
|
use std::{
|
||||||
fmt,
|
|
||||||
hash::{Hash, Hasher},
|
|
||||||
io::{Read, Write},
|
io::{Read, Write},
|
||||||
sync::{atomic::AtomicBool, Arc},
|
sync::{atomic::AtomicBool, Arc},
|
||||||
};
|
};
|
||||||
|
|
||||||
use bollard::{
|
use bollard::{
|
||||||
container,
|
|
||||||
exec::{CreateExecOptions, StartExecOptions, StartExecResults},
|
exec::{CreateExecOptions, StartExecOptions, StartExecResults},
|
||||||
Docker,
|
Docker,
|
||||||
};
|
};
|
||||||
@@ -18,8 +15,6 @@ use tokio::io::{AsyncReadExt, AsyncWriteExt};
|
|||||||
use crate::{
|
use crate::{
|
||||||
app_data::{AppData, ContainerId, State},
|
app_data::{AppData, ContainerId, State},
|
||||||
app_error::AppError,
|
app_error::AppError,
|
||||||
parse_args::CliArgs,
|
|
||||||
ui::{GuiState, Status},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// TTY location
|
/// TTY location
|
||||||
@@ -304,8 +299,6 @@ impl ExecMode {
|
|||||||
// RESET TERMINAL BEFROEHAND
|
// RESET TERMINAL BEFROEHAND
|
||||||
pub async fn run(
|
pub async fn run(
|
||||||
&self,
|
&self,
|
||||||
app_data: &Arc<Mutex<AppData>>,
|
|
||||||
gui_state: &Arc<Mutex<GuiState>>,
|
|
||||||
) -> Result<(), AppError> {
|
) -> Result<(), AppError> {
|
||||||
match self {
|
match self {
|
||||||
Self::External(id) => {
|
Self::External(id) => {
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
use std::{
|
use std::{
|
||||||
fs::OpenOptions,
|
fs::OpenOptions,
|
||||||
io::{BufWriter, Write},
|
io::{BufWriter, Write},
|
||||||
path::Path,
|
|
||||||
sync::{
|
sync::{
|
||||||
atomic::{AtomicBool, Ordering},
|
atomic::{AtomicBool, Ordering},
|
||||||
Arc,
|
Arc,
|
||||||
@@ -18,10 +17,7 @@ use crossterm::{
|
|||||||
use futures_util::StreamExt;
|
use futures_util::StreamExt;
|
||||||
use parking_lot::Mutex;
|
use parking_lot::Mutex;
|
||||||
use ratatui::layout::Rect;
|
use ratatui::layout::Rect;
|
||||||
use tokio::{
|
use tokio::sync::mpsc::{Receiver, Sender};
|
||||||
sync::mpsc::{Receiver, Sender},
|
|
||||||
task::JoinHandle,
|
|
||||||
};
|
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
mod message;
|
mod message;
|
||||||
@@ -40,7 +36,6 @@ pub struct InputHandler {
|
|||||||
app_data: Arc<Mutex<AppData>>,
|
app_data: Arc<Mutex<AppData>>,
|
||||||
docker_sender: Sender<DockerMessage>,
|
docker_sender: Sender<DockerMessage>,
|
||||||
gui_state: Arc<Mutex<GuiState>>,
|
gui_state: Arc<Mutex<GuiState>>,
|
||||||
info_sleep: Option<JoinHandle<()>>,
|
|
||||||
is_running: Arc<AtomicBool>,
|
is_running: Arc<AtomicBool>,
|
||||||
mouse_capture: bool,
|
mouse_capture: bool,
|
||||||
rec: Receiver<InputMessages>,
|
rec: Receiver<InputMessages>,
|
||||||
@@ -62,7 +57,6 @@ impl InputHandler {
|
|||||||
is_running,
|
is_running,
|
||||||
rec,
|
rec,
|
||||||
mouse_capture: true,
|
mouse_capture: true,
|
||||||
info_sleep: None,
|
|
||||||
};
|
};
|
||||||
inner.start().await;
|
inner.start().await;
|
||||||
}
|
}
|
||||||
@@ -132,7 +126,6 @@ impl InputHandler {
|
|||||||
/// Validate that one can exec into a Docker container
|
/// Validate that one can exec into a Docker container
|
||||||
async fn e_key(&self) {
|
async fn e_key(&self) {
|
||||||
let is_oxker = self.app_data.lock().is_oxker();
|
let is_oxker = self.app_data.lock().is_oxker();
|
||||||
let mut exec_err = Some(());
|
|
||||||
if !is_oxker && tty_readable() {
|
if !is_oxker && tty_readable() {
|
||||||
let uuid = Uuid::new_v4();
|
let uuid = Uuid::new_v4();
|
||||||
let handle = GuiState::start_loading_animation(&self.gui_state, uuid);
|
let handle = GuiState::start_loading_animation(&self.gui_state, uuid);
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ use crate::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
gui_state::{self, BoxLocation, DeleteButton, Region},
|
gui_state::{BoxLocation, DeleteButton, Region},
|
||||||
FrameData,
|
FrameData,
|
||||||
};
|
};
|
||||||
use super::{GuiState, SelectablePanel};
|
use super::{GuiState, SelectablePanel};
|
||||||
|
|||||||
+2
-7
@@ -1,5 +1,4 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use bollard::Docker;
|
|
||||||
use crossterm::{
|
use crossterm::{
|
||||||
event::{self, DisableMouseCapture, Event},
|
event::{self, DisableMouseCapture, Event},
|
||||||
execute,
|
execute,
|
||||||
@@ -29,13 +28,11 @@ pub use self::gui_state::{DeleteButton, GuiState, SelectablePanel, Status};
|
|||||||
use crate::{
|
use crate::{
|
||||||
app_data::{AppData, Columns, ContainerId, Header, SortedOrder},
|
app_data::{AppData, Columns, ContainerId, Header, SortedOrder},
|
||||||
app_error::AppError,
|
app_error::AppError,
|
||||||
docker_data::DockerMessage,
|
|
||||||
input_handler::InputMessages,
|
input_handler::InputMessages,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub struct Ui {
|
pub struct Ui {
|
||||||
app_data: Arc<Mutex<AppData>>,
|
app_data: Arc<Mutex<AppData>>,
|
||||||
docker_sx: Sender<DockerMessage>,
|
|
||||||
gui_state: Arc<Mutex<GuiState>>,
|
gui_state: Arc<Mutex<GuiState>>,
|
||||||
input_poll_rate: Duration,
|
input_poll_rate: Duration,
|
||||||
is_running: Arc<AtomicBool>,
|
is_running: Arc<AtomicBool>,
|
||||||
@@ -61,7 +58,6 @@ impl Ui {
|
|||||||
/// Create a new Ui struct, and execute the drawing loop
|
/// Create a new Ui struct, and execute the drawing loop
|
||||||
pub async fn create(
|
pub async fn create(
|
||||||
app_data: Arc<Mutex<AppData>>,
|
app_data: Arc<Mutex<AppData>>,
|
||||||
docker_sx: Sender<DockerMessage>,
|
|
||||||
gui_state: Arc<Mutex<GuiState>>,
|
gui_state: Arc<Mutex<GuiState>>,
|
||||||
is_running: Arc<AtomicBool>,
|
is_running: Arc<AtomicBool>,
|
||||||
sender: Sender<InputMessages>,
|
sender: Sender<InputMessages>,
|
||||||
@@ -71,7 +67,6 @@ impl Ui {
|
|||||||
let cursor_position = terminal.get_cursor().unwrap_or_default();
|
let cursor_position = terminal.get_cursor().unwrap_or_default();
|
||||||
let mut ui = Self {
|
let mut ui = Self {
|
||||||
app_data,
|
app_data,
|
||||||
docker_sx,
|
|
||||||
gui_state,
|
gui_state,
|
||||||
input_poll_rate: std::time::Duration::from_millis(100),
|
input_poll_rate: std::time::Duration::from_millis(100),
|
||||||
is_running,
|
is_running,
|
||||||
@@ -147,12 +142,12 @@ impl Ui {
|
|||||||
|
|
||||||
/// Use exeternal docker cli to exec into a container
|
/// Use exeternal docker cli to exec into a container
|
||||||
async fn exec(&mut self) {
|
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 {
|
if let Some(mode) = exec_mode {
|
||||||
self.reset_terminal().ok();
|
self.reset_terminal().ok();
|
||||||
self.terminal.clear().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
|
self.app_data
|
||||||
.lock()
|
.lock()
|
||||||
.set_error(e, &self.gui_state, Status::Error);
|
.set_error(e, &self.gui_state, Status::Error);
|
||||||
|
|||||||
Reference in New Issue
Block a user