diff options
author | Ulrich Kautz <ulrichkautz@fb.com> | 2022-01-24 16:34:06 +0000 |
---|---|---|
committer | Ulrich Kautz <ulrichkautz@fb.com> | 2022-01-27 13:31:31 +0000 |
commit | 63e31baa74b242160cc27382e953732de0519406 (patch) | |
tree | 90cf9c60ed50acace55700322affa8eaa8297633 /src | |
parent | 9d20d3df3641b1c8fcd72fded14743db21ceafa4 (diff) |
Add build feature to disable command execution
This CL adds the build feature `disable-command-execution` that enforces the `--print` flag and thereby disables execution of commands.
Diffstat (limited to 'src')
-rw-r--r-- | src/config/cli.rs | 1 | ||||
-rw-r--r-- | src/config/mod.rs | 12 |
2 files changed, 12 insertions, 1 deletions
diff --git a/src/config/cli.rs b/src/config/cli.rs index aa633f5..eb5d53a 100644 --- a/src/config/cli.rs +++ b/src/config/cli.rs @@ -97,6 +97,7 @@ pub(super) struct ClapConfig { /// Instead of executing a snippet, prints it to stdout #[clap(long)] + #[cfg(not(feature = "disable-command-execution"))] pub print: bool, /// Returns the best match diff --git a/src/config/mod.rs b/src/config/mod.rs index cb977b1..974cfdf 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -136,8 +136,18 @@ impl Config { self.yaml.style.comment.min_width } + #[cfg(feature = "disable-command-execution")] + fn print(&self) -> bool { + true + } + + #[cfg(not(feature = "disable-command-execution"))] + fn print(&self) -> bool { + self.clap.print + } + pub fn action(&self) -> Action { - if self.clap.print { + if self.print() { Action::Print } else { Action::Execute |