From 4ea5307c2d2fe6ba3e8d3f554aca54c484808e52 Mon Sep 17 00:00:00 2001 From: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> Date: Mon, 7 Apr 2025 22:55:32 +0200 Subject: [PATCH] Fixes issues Signed-off-by: alexis-opolka <53085471+alexis-opolka@users.noreply.github.com> --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/config/mod.rs | 6 ++++++ src/libs/dns_common/tracing.rs | 29 ----------------------------- src/parser.rs | 6 +++--- 5 files changed, 11 insertions(+), 34 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9833cfb..064197e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -375,7 +375,7 @@ dependencies = [ [[package]] name = "navi" -version = "2.24.0" +version = "2.25.0-beta1" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index 466ca18..7a0617f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "navi" -version = "2.24.0" +version = "2.25.0-beta1" authors = ["Denis Isidoro "] edition = "2021" description = "An interactive cheatsheet tool for the command-line" diff --git a/src/config/mod.rs b/src/config/mod.rs index cc788da..902b2f8 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -196,3 +196,9 @@ impl Config { } } } + +impl Default for Config { + fn default() -> Self { + Self::new() + } +} diff --git a/src/libs/dns_common/tracing.rs b/src/libs/dns_common/tracing.rs index 3b711b4..8e4ac3b 100644 --- a/src/libs/dns_common/tracing.rs +++ b/src/libs/dns_common/tracing.rs @@ -1,8 +1,4 @@ use crate::prelude::*; -use std::env; -use tracing_subscriber::EnvFilter; - -static RUST_LOG: &str = "RUST_LOG"; #[derive(Deserialize, Serialize, Debug, Clone)] #[serde(deny_unknown_fields)] @@ -10,28 +6,3 @@ pub struct TracingConfig { pub time: bool, pub level: String, } - -pub fn init(config: Option<&TracingConfig>) { - if let Some(tracing) = config { - let level_is_set = match env::var(RUST_LOG) { - Err(_) => false, - Ok(v) => !v.is_empty(), - }; - - if !level_is_set { - env::set_var(RUST_LOG, &tracing.level); - } - - let filter = EnvFilter::from_default_env(); - let t = tracing_subscriber::fmt().with_env_filter(filter); - let res = if tracing.time { - t.try_init() - } else { - t.without_time().try_init() - }; - - if let Err(e) = res { - error!("unable to set tracing subscriber: {}", e); - } - } -} diff --git a/src/parser.rs b/src/parser.rs index e1d4d2b..fad0390 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -225,10 +225,10 @@ impl<'a> Parser<'a> { let write_fn = self.write_fn; - return self + self .writer .write_all(write_fn(item).as_bytes()) - .context("Failed to write command to finder's stdin"); + .context("Failed to write command to finder's stdin") } pub fn read_lines( @@ -345,7 +345,7 @@ mod tests { let opts = command_options.unwrap(); assert_eq!(opts.header_lines, 0); assert_eq!(opts.column, None); - assert_eq!(opts.delimiter, None); + assert_eq!(opts.delimiter, Some("\\s\\s".to_string())); assert_eq!(opts.suggestion_type, SuggestionType::SingleSelection); } }