feat: option to include duplicate commands when printing history commands

This commit is contained in:
lilydjwg 2024-10-04 22:58:00 +08:00
parent 80e950c648
commit b331eef4df
2 changed files with 9 additions and 1 deletions

View File

@ -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 {
@ -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);

View File

@ -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 {
@ -215,6 +219,7 @@ impl Cmd {
limit: self.limit,
offset: self.offset,
reverse: self.reverse,
include_duplicates: self.include_duplicates,
};
let mut entries =