mirror of
https://github.com/denisidoro/navi
synced 2024-11-22 03:23:05 +00:00
Merge pull request #678 from ukautz/feature/disable-command-execution
Add build feature to disable command execution
This commit is contained in:
commit
9f949a30c4
3 changed files with 15 additions and 1 deletions
|
@ -11,6 +11,9 @@ keywords = ["cheatsheets", "terminal", "cli", "tui", "shell"]
|
||||||
categories = ["command-line-utilities"]
|
categories = ["command-line-utilities"]
|
||||||
license = "Apache-2.0"
|
license = "Apache-2.0"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
disable-command-execution = []
|
||||||
|
|
||||||
[badges]
|
[badges]
|
||||||
travis-ci = { repository = "denisidoro/navi", branch = "master" }
|
travis-ci = { repository = "denisidoro/navi", branch = "master" }
|
||||||
|
|
||||||
|
|
|
@ -97,6 +97,7 @@ pub(super) struct ClapConfig {
|
||||||
|
|
||||||
/// Instead of executing a snippet, prints it to stdout
|
/// Instead of executing a snippet, prints it to stdout
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
|
#[cfg(not(feature = "disable-command-execution"))]
|
||||||
pub print: bool,
|
pub print: bool,
|
||||||
|
|
||||||
/// Returns the best match
|
/// Returns the best match
|
||||||
|
|
|
@ -136,8 +136,18 @@ impl Config {
|
||||||
self.yaml.style.comment.min_width
|
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 {
|
pub fn action(&self) -> Action {
|
||||||
if self.clap.print {
|
if self.print() {
|
||||||
Action::Print
|
Action::Print
|
||||||
} else {
|
} else {
|
||||||
Action::Execute
|
Action::Execute
|
||||||
|
|
Loading…
Reference in a new issue