Skip to content

Commit

Permalink
Search: Allow specifiying the limited of returned entries (#364)
Browse files Browse the repository at this point in the history
This patch adds a new option to the search command, allowing to limit
the returned results from the database.
  • Loading branch information
networkException authored Apr 28, 2022
1 parent 93ab4e7 commit 9d2e9ea
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/command/client/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ pub struct Cmd {
#[clap(long)]
after: Option<String>,

/// How many entries to return at most
#[clap(long)]
limit: Option<i64>,

/// Open interactive search UI
#[clap(long, short)]
interactive: bool,
Expand Down Expand Up @@ -97,6 +101,7 @@ impl Cmd {
self.exclude_cwd,
self.before,
self.after,
self.limit,
&self.query,
db,
)
Expand Down Expand Up @@ -589,6 +594,7 @@ async fn run_non_interactive(
exclude_cwd: Option<String>,
before: Option<String>,
after: Option<String>,
limit: Option<i64>,
query: &[String],
db: &mut (impl Database + Send + Sync),
) -> Result<()> {
Expand All @@ -606,7 +612,7 @@ async fn run_non_interactive(

let results = db
.search(
None,
limit,
settings.search_mode,
settings.filter_mode,
&context,
Expand Down

0 comments on commit 9d2e9ea

Please sign in to comment.