diff --git a/src/commands/core/actor.rs b/src/commands/core/actor.rs index 62bda25..36e2960 100644 --- a/src/commands/core/actor.rs +++ b/src/commands/core/actor.rs @@ -146,6 +146,11 @@ fn unique_result_count(results: &[&str]) -> usize { fn replace_variables_from_snippet(snippet: &str, tags: &str, variables: VariableMap) -> Result { 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); diff --git a/src/config/cli.rs b/src/config/cli.rs index 431b1da..7e2ec20 100644 --- a/src/config/cli.rs +++ b/src/config/cli.rs @@ -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, diff --git a/src/config/mod.rs b/src/config/mod.rs index 1126b05..6da5382 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -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() }