mirror of
https://github.com/ouch-org/ouch.git
synced 2025-06-06 19:45:29 +00:00
handle logger thread in main function
This commit is contained in:
parent
25d7d3d870
commit
c56978d1e7
@ -18,7 +18,7 @@ use crate::{
|
|||||||
list::ListOptions,
|
list::ListOptions,
|
||||||
utils::{
|
utils::{
|
||||||
self,
|
self,
|
||||||
logger::{info_accessible, spawn_logger_thread, warning},
|
logger::{info_accessible, warning},
|
||||||
to_utf, EscapedPathDisplay, FileVisibilityPolicy,
|
to_utf, EscapedPathDisplay, FileVisibilityPolicy,
|
||||||
},
|
},
|
||||||
CliArgs, QuestionPolicy,
|
CliArgs, QuestionPolicy,
|
||||||
@ -52,18 +52,6 @@ pub fn run(
|
|||||||
args: CliArgs,
|
args: CliArgs,
|
||||||
question_policy: QuestionPolicy,
|
question_policy: QuestionPolicy,
|
||||||
file_visibility_policy: FileVisibilityPolicy,
|
file_visibility_policy: FileVisibilityPolicy,
|
||||||
) -> crate::Result<()> {
|
|
||||||
let handler = spawn_logger_thread();
|
|
||||||
run_cmd(args, question_policy, file_visibility_policy)?;
|
|
||||||
handler.shutdown_and_wait();
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn run_cmd(
|
|
||||||
args: CliArgs,
|
|
||||||
question_policy: QuestionPolicy,
|
|
||||||
file_visibility_policy: FileVisibilityPolicy,
|
|
||||||
) -> crate::Result<()> {
|
) -> crate::Result<()> {
|
||||||
match args.cmd {
|
match args.cmd {
|
||||||
Subcommand::Compress {
|
Subcommand::Compress {
|
||||||
|
@ -18,6 +18,8 @@ use error::{Error, Result};
|
|||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use utils::{QuestionAction, QuestionPolicy};
|
use utils::{QuestionAction, QuestionPolicy};
|
||||||
|
|
||||||
|
use crate::utils::logger::spawn_logger_thread;
|
||||||
|
|
||||||
// Used in BufReader and BufWriter to perform less syscalls
|
// Used in BufReader and BufWriter to perform less syscalls
|
||||||
const BUFFER_CAPACITY: usize = 1024 * 32;
|
const BUFFER_CAPACITY: usize = 1024 * 32;
|
||||||
|
|
||||||
@ -28,7 +30,11 @@ static CURRENT_DIRECTORY: Lazy<PathBuf> = Lazy::new(|| env::current_dir().unwrap
|
|||||||
pub const EXIT_FAILURE: i32 = libc::EXIT_FAILURE;
|
pub const EXIT_FAILURE: i32 = libc::EXIT_FAILURE;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
if let Err(err) = run() {
|
let handler = spawn_logger_thread();
|
||||||
|
let result = run();
|
||||||
|
handler.shutdown_and_wait();
|
||||||
|
|
||||||
|
if let Err(err) = result {
|
||||||
eprintln!("{err}");
|
eprintln!("{err}");
|
||||||
std::process::exit(EXIT_FAILURE);
|
std::process::exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user