Skip to content

Commit

Permalink
feat: option to include duplicate commands when printing history comm…
Browse files Browse the repository at this point in the history
…ands
  • Loading branch information
lilydjwg committed Oct 4, 2024
1 parent 80e950c commit b331eef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion crates/atuin-client/src/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub struct OptFilters {
pub limit: Option<i64>,
pub offset: Option<i64>,
pub reverse: bool,
pub include_duplicates: bool,
}

pub fn current_context() -> Context {
Expand Down Expand Up @@ -403,7 +404,9 @@ impl Database for Sqlite {
) -> Result<Vec<History>> {
let mut sql = SqlBuilder::select_from("history");

sql.group_by("command").having("max(timestamp)");
if !filter_options.include_duplicates {
sql.group_by("command").having("max(timestamp)");
}

if let Some(limit) = filter_options.limit {
sql.limit(limit);
Expand Down
5 changes: 5 additions & 0 deletions crates/atuin/src/command/client/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ pub struct Cmd {
/// Set the maximum number of lines Atuin's interface should take up.
#[arg(long = "inline-height")]
inline_height: Option<u16>,

/// Include duplicate commands in the output (non-interactive only)
#[arg(long)]
include_duplicates: bool,
}

impl Cmd {
Expand Down Expand Up @@ -215,6 +219,7 @@ impl Cmd {
limit: self.limit,
offset: self.offset,
reverse: self.reverse,
include_duplicates: self.include_duplicates,
};

let mut entries =
Expand Down

0 comments on commit b331eef

Please sign in to comment.