Skip to content

Commit

Permalink
feat(complete): Provide a way to disable env completions
Browse files Browse the repository at this point in the history
You can remove the env variable but sometimes you want to override it.
  • Loading branch information
epage committed Jan 29, 2025
1 parent c4105bd commit f5fc765
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clap_complete/src/env/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@
//! ```zsh
//! echo "source <(COMPLETE=zsh your_program)" >> ~/.zshrc
//! ```
//!
//! To disable completions, you can set `COMPLETE=` or `COMPLETE=0`
mod shells;

Expand Down Expand Up @@ -218,6 +220,9 @@ impl<'s, F: Fn() -> clap::Command> CompleteEnv<'s, F> {
let Some(name) = std::env::var_os(self.var) else {
return Ok(false);
};
if name.is_empty() || name == "0" {
return Ok(false);
}

// Ensure any child processes called for custom completers don't activate their own
// completion logic.
Expand Down

0 comments on commit f5fc765

Please sign in to comment.