mirror of
https://github.com/denisidoro/navi
synced 2024-11-24 04:23:06 +00:00
Add --prevent-interpolation flag (#824)
This commit is contained in:
parent
a72add9d80
commit
e3920552ca
3 changed files with 13 additions and 0 deletions
|
@ -146,6 +146,11 @@ fn unique_result_count(results: &[&str]) -> usize {
|
|||
|
||||
fn replace_variables_from_snippet(snippet: &str, tags: &str, variables: VariableMap) -> Result<String> {
|
||||
let mut interpolated_snippet = String::from(snippet);
|
||||
|
||||
if CONFIG.prevent_interpolation() {
|
||||
return Ok(interpolated_snippet);
|
||||
}
|
||||
|
||||
let variables_found: Vec<&str> = deser::VAR_REGEX.find_iter(snippet).map(|m| m.as_str()).collect();
|
||||
let variable_count = unique_result_count(&variables_found);
|
||||
|
||||
|
|
|
@ -52,6 +52,10 @@ pub(super) struct ClapConfig {
|
|||
#[arg(long)]
|
||||
pub best_match: bool,
|
||||
|
||||
/// Prevents variable interpolation
|
||||
#[arg(long)]
|
||||
pub prevent_interpolation: bool,
|
||||
|
||||
/// Searches for cheatsheets using the tldr-pages repository
|
||||
#[arg(long)]
|
||||
pub tldr: Option<String>,
|
||||
|
|
|
@ -35,6 +35,10 @@ impl Config {
|
|||
self.clap.best_match
|
||||
}
|
||||
|
||||
pub fn prevent_interpolation(&self) -> bool {
|
||||
self.clap.prevent_interpolation
|
||||
}
|
||||
|
||||
pub fn cmd(&self) -> Option<&Command> {
|
||||
self.clap.cmd.as_ref()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue