Add --offset
flag to atuin search
(#825)
This flag allows the user to continue searching at an offset. This is useful for building tools that use atuin to search for previous commands and return only one result. ``` atuin search --limit 1 atuin search --limit 1 --offset 1 atuin search --limit 1 --offset 2 ```
This commit is contained in:
parent
f3a3f1c774
commit
fa0a1447a6
2 changed files with 10 additions and 0 deletions
|
@ -34,6 +34,7 @@ pub struct OptFilters {
|
|||
pub before: Option<String>,
|
||||
pub after: Option<String>,
|
||||
pub limit: Option<i64>,
|
||||
pub offset: Option<i64>,
|
||||
}
|
||||
|
||||
pub fn current_context() -> Context {
|
||||
|
@ -361,6 +362,10 @@ impl Database for Sqlite {
|
|||
sql.limit(limit);
|
||||
}
|
||||
|
||||
if let Some(offset) = filter_options.offset {
|
||||
sql.offset(offset);
|
||||
}
|
||||
|
||||
match filter {
|
||||
FilterMode::Global => &mut sql,
|
||||
FilterMode::Host => sql.and_where_eq("hostname", quote(&context.hostname)),
|
||||
|
|
|
@ -49,6 +49,10 @@ pub struct Cmd {
|
|||
#[arg(long)]
|
||||
limit: Option<i64>,
|
||||
|
||||
/// Offset from the start of the results
|
||||
#[arg(long)]
|
||||
offset: Option<i64>,
|
||||
|
||||
/// Open interactive search UI
|
||||
#[arg(long, short)]
|
||||
interactive: bool,
|
||||
|
@ -111,6 +115,7 @@ impl Cmd {
|
|||
before: self.before,
|
||||
after: self.after,
|
||||
limit: self.limit,
|
||||
offset: self.offset,
|
||||
};
|
||||
|
||||
let mut entries =
|
||||
|
|
Loading…
Reference in a new issue