summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTymanWasTaken <tbeckman530@gmail.com>2022-11-02 14:47:16 -0600
committerGitHub <noreply@github.com>2022-11-02 20:47:16 +0000
commit6e3304b485a0bab3d41ad5746cd607c8a8b3f38c (patch)
treed0c8a14c7c4710da4f95ab6b3e54ebda74962cc1 /src
parentf1f40a0d55cc156441e9c35781dbfd7e57e03782 (diff)
Exit with return code 1 when no results are found in `atuin search` command (#489)
* Exit with return code 1 when no results are found in `atuin search` command * Remove random whitespace
Diffstat (limited to 'src')
-rw-r--r--src/command/client/search.rs9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/command/client/search.rs b/src/command/client/search.rs
index da9157745..b87b86c98 100644
--- a/src/command/client/search.rs
+++ b/src/command/client/search.rs
@@ -67,7 +67,7 @@ impl Cmd {
eprintln!("{}", item);
} else {
let list_mode = ListMode::from_flags(self.human, self.cmd_only);
- run_non_interactive(
+ let entries = run_non_interactive(
settings,
list_mode,
self.cwd,
@@ -81,6 +81,9 @@ impl Cmd {
db,
)
.await?;
+ if entries == 0 {
+ std::process::exit(1)
+ }
};
Ok(())
}
@@ -101,7 +104,7 @@ async fn run_non_interactive(
limit: Option<i64>,
query: &[String],
db: &mut impl Database,
-) -> Result<()> {
+) -> Result<usize> {
let dir = if cwd.as_deref() == Some(".") {
let current = std::env::current_dir()?;
let current = current.as_os_str();
@@ -177,5 +180,5 @@ async fn run_non_interactive(
.collect();
super::history::print_list(&results, list_mode);
- Ok(())
+ Ok(results.len())
}