mirror of
https://github.com/ChrisTitusTech/linutil.git
synced 2025-02-21 16:45:11 +00:00
fix: panics
This commit is contained in:
parent
a429ab2667
commit
661398da44
|
@ -37,7 +37,7 @@ pub struct RunningCommand {
|
||||||
writer: Box<dyn Write + Send>,
|
writer: Box<dyn Write + Send>,
|
||||||
/// Only set after the process has ended
|
/// Only set after the process has ended
|
||||||
status: Option<ExitStatus>,
|
status: Option<ExitStatus>,
|
||||||
log_saved_path: Option<String>,
|
log_path: Option<String>,
|
||||||
scroll_offset: usize,
|
scroll_offset: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ impl FloatContent for RunningCommand {
|
||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.title_top(title_line.centered());
|
.title_top(title_line.centered());
|
||||||
|
|
||||||
if let Some(log_path) = &self.log_saved_path {
|
if let Some(log_path) = &self.log_path {
|
||||||
block =
|
block =
|
||||||
block.title_bottom(Line::from(format!(" Log saved: {} ", log_path)).centered());
|
block.title_bottom(Line::from(format!(" Log saved: {} ", log_path)).centered());
|
||||||
} else {
|
} else {
|
||||||
|
@ -120,9 +120,9 @@ impl FloatContent for RunningCommand {
|
||||||
KeyCode::PageDown => {
|
KeyCode::PageDown => {
|
||||||
self.scroll_offset = self.scroll_offset.saturating_sub(10);
|
self.scroll_offset = self.scroll_offset.saturating_sub(10);
|
||||||
}
|
}
|
||||||
KeyCode::Char('l') => {
|
KeyCode::Char('l') if self.is_finished() => {
|
||||||
if let Ok(log_path) = self.save_log() {
|
if let Ok(log_path) = self.save_log() {
|
||||||
self.log_saved_path = Some(log_path);
|
self.log_path = Some(log_path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Pass other key events to the terminal
|
// Pass other key events to the terminal
|
||||||
|
@ -251,7 +251,7 @@ impl RunningCommand {
|
||||||
pty_master: pair.master,
|
pty_master: pair.master,
|
||||||
writer,
|
writer,
|
||||||
status: None,
|
status: None,
|
||||||
log_saved_path: None,
|
log_path: None,
|
||||||
scroll_offset: 0,
|
scroll_offset: 0,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -301,12 +301,12 @@ impl RunningCommand {
|
||||||
|
|
||||||
fn save_log(&self) -> std::io::Result<String> {
|
fn save_log(&self) -> std::io::Result<String> {
|
||||||
let mut log_path = std::env::temp_dir();
|
let mut log_path = std::env::temp_dir();
|
||||||
let format = format_description!("[year]-[month]-[day]-[hour]-[minute]-[second]");
|
let date_format = format_description!("[year]-[month]-[day]-[hour]-[minute]-[second]");
|
||||||
log_path.push(format!(
|
log_path.push(format!(
|
||||||
"linutil_log_{}.log",
|
"linutil_log_{}.log",
|
||||||
OffsetDateTime::now_local()
|
OffsetDateTime::now_local()
|
||||||
.unwrap()
|
.unwrap_or(OffsetDateTime::now_utc())
|
||||||
.format(&format)
|
.format(&date_format)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user