various: validate lower and upper boundaries before storing; add CLI flags

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I6484f9579a8799d952b15adcb47c8eec6a6a6964
This commit is contained in:
raf 2026-02-26 17:02:45 +03:00
commit 3a14860ae1
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
4 changed files with 68 additions and 33 deletions

View file

@ -2,6 +2,7 @@ use std::io::Read;
use crate::db::{ClipboardDb, SqliteClipboardDb};
#[allow(clippy::too_many_arguments)]
pub trait StoreCommand {
fn store(
&self,
@ -10,6 +11,8 @@ pub trait StoreCommand {
max_items: u64,
state: Option<String>,
excluded_apps: &[String],
min_size: Option<usize>,
max_size: usize,
) -> Result<(), crate::db::StashError>;
}
@ -21,6 +24,8 @@ impl StoreCommand for SqliteClipboardDb {
max_items: u64,
state: Option<String>,
excluded_apps: &[String],
min_size: Option<usize>,
max_size: usize,
) -> Result<(), crate::db::StashError> {
if let Some("sensitive" | "clear") = state.as_deref() {
self.delete_last()?;
@ -31,6 +36,8 @@ impl StoreCommand for SqliteClipboardDb {
max_dedupe_search,
max_items,
Some(excluded_apps),
min_size,
max_size,
)?;
log::info!("Entry stored");
}