use crate::{history::History, Ctx, QuartzResult};
#[derive(clap::Args, Debug)]
pub struct Args {
#[arg(short = 'n', long, value_name = "N")]
max_count: Option<usize>,
}
pub fn cmd(ctx: &Ctx, args: Args) -> QuartzResult {
let history = History::new(ctx)?;
let mut count = 0;
let max_count = args.max_count.unwrap_or(usize::MAX);
let mut output = String::new();
for entry in history.entries(ctx) {
if count >= max_count {
break;
}
count += 1;
if count != 1 {
output.push('\n');
}
output.push_str(&format!("{entry}\n"));
}
ctx.paginate(output.as_bytes())?;
Ok(())
}