Log error if command fails

pull/3/head
Arijit Basu 3 years ago
parent b03618737c
commit 2432673483
No known key found for this signature in database
GPG Key ID: 7D7BF809E7378863

2
Cargo.lock generated

@ -1164,7 +1164,7 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "xplr"
version = "0.2.17"
version = "0.2.18"
dependencies = [
"anyhow",
"chrono",

@ -1,6 +1,6 @@
[package]
name = "xplr"
version = "0.2.17" # Update app.rs
version = "0.2.18" # Update app.rs
authors = ["Arijit Basu <sayanarijit@gmail.com>"]
edition = "2018"
description = "A hackable, minimal, fast TUI file explorer, stealing ideas from nnn and fzf"

@ -14,7 +14,7 @@ use std::fs;
use std::io;
use std::path::PathBuf;
pub const VERSION: &str = "v0.2.17"; // Update Cargo.toml
pub const VERSION: &str = "v0.2.18"; // Update Cargo.toml
pub const TEMPLATE_TABLE_ROW: &str = "TEMPLATE_TABLE_ROW";

@ -207,7 +207,7 @@ fn main() -> Result<()> {
let session_path = app.session_path();
let result = app.result_str();
let _ = std::process::Command::new(cmd.command.clone())
let status = std::process::Command::new(cmd.command.clone())
.current_dir(app.pwd())
.env("XPLR_PID", pid)
.env("XPLR_INPUT_BUFFER", input_buffer)
@ -224,7 +224,20 @@ fn main() -> Result<()> {
.env("XPLR_DIRECTORY_NODES", directory_nodes)
.env("XPLR_LOGS", logs)
.args(cmd.args.clone())
.status();
.status()
.map(|s| {
if s.success() {
Ok(())
} else {
Err(format!("process exited with code {}", &s))
}
})
.unwrap_or_else(|e| Err(e.to_string()));
if let Err(e) = status {
let msg = app::MsgIn::External(app::ExternalMsg::LogError(e));
tx_msg_in.send(app::Task::new(1, msg, None))?;
};
terminal.hide_cursor()?;
execute!(terminal.backend_mut(), term::EnterAlternateScreen)?;

Loading…
Cancel
Save