diff --git a/scripts/fix b/scripts/fix index d70605e..e25c8ac 100755 --- a/scripts/fix +++ b/scripts/fix @@ -6,21 +6,21 @@ source "${NAVI_HOME}/scripts/install" cd "$NAVI_HOME" -header "Cargo nighly fix..." +header "cargo clippy fix..." cargo +nightly clippy --fix -Z unstable-options || true -header "Cargo fix..." +header "cargo fix..." cargo fix || true -header "Cargo fmt..." +header "cargo fmt..." cargo fmt || true +header "clippy..." +cargo clippy || true + header "dot code beautify..." find scripts -type f | xargs -I% dot code beautify % || true dot code beautify "${NAVI_HOME}/alfred/alfred.bash" || true dot code beautify "${NAVI_HOME}/alfred/alfred2.bash" || true dot code beautify "${NAVI_HOME}/tests/core.bash" || true dot code beautify "${NAVI_HOME}/tests/run" || true - -header "clippy..." -cargo clippy || true diff --git a/src/cheatsh.rs b/src/cheatsh.rs index 800928b..e0684cd 100644 --- a/src/cheatsh.rs +++ b/src/cheatsh.rs @@ -4,17 +4,11 @@ use crate::parser; use crate::structures::cheat::VariableMap; use anyhow::Context; use anyhow::Error; -use regex::Regex; use std::collections::HashSet; use std::process::{self, Command, Stdio}; -lazy_static! { - static ref UNKNOWN_TOPIC_REGEX: Regex = Regex::new(r"^Unknown topic\.").expect("Invalid regex"); -} - -fn map_line(line: &str) -> Result { - let line = line.trim().trim_end_matches(':'); - Ok(line.to_string()) +fn map_line(line: &str) -> String { + line.trim().trim_end_matches(':').to_string() } fn lines(query: &str, markdown: &str) -> impl Iterator> { @@ -24,7 +18,7 @@ fn lines(query: &str, markdown: &str) -> impl Iterator>>() .into_iter() } @@ -38,7 +32,7 @@ fn read_all( let mut variables = VariableMap::new(); let mut visited_lines = HashSet::new(); - if UNKNOWN_TOPIC_REGEX.is_match(cheat) { + if cheat.starts_with("Unknown topic.") { eprintln!( "`{}` not found in cheatsh. diff --git a/src/tldr.rs b/src/tldr.rs index ae10f80..2c30a99 100644 --- a/src/tldr.rs +++ b/src/tldr.rs @@ -34,9 +34,9 @@ fn convert_tldr_vars(line: &str) -> String { new_line } -fn convert_tldr(line: &str) -> Result { +fn convert_tldr(line: &str) -> String { let line = line.trim(); - let new_line = if line.starts_with('-') { + if line.starts_with('-') { format!("{}{}", "# ", &line[2..line.len() - 1]) } else if line.starts_with('`') { convert_tldr_vars(&line[1..line.len() - 1]) @@ -44,8 +44,7 @@ fn convert_tldr(line: &str) -> Result { line.to_string() } else { "".to_string() - }; - Ok(new_line) + } } fn markdown_lines(query: &str, markdown: &str) -> impl Iterator> { @@ -55,7 +54,7 @@ fn markdown_lines(query: &str, markdown: &str) -> impl Iterator>>() .into_iter() }