listing all files

This commit is contained in:
Andrei Stoica 2024-04-01 22:00:40 -04:00
parent ddd620a021
commit 9fe6ae5eb8
2 changed files with 8 additions and 1 deletions

View File

@ -17,6 +17,9 @@ pub struct Args {
/// list closest files to date /// list closest files to date
#[arg(short, long)] #[arg(short, long)]
pub list: bool, pub list: bool,
/// number of files to list
#[arg(short, long, default_value_t = 5)]
pub number: usize,
/// list closest files to date /// list closest files to date
#[arg(short = 'L', long)] #[arg(short = 'L', long)]
pub list_all: bool, pub list_all: bool,

View File

@ -79,7 +79,11 @@ fn main() {
let today = Local::now().date_naive(); let today = Local::now().date_naive();
let target = today - TimeDelta::try_days(args.previous.into()).unwrap(); let target = today - TimeDelta::try_days(args.previous.into()).unwrap();
let closest_files = TodoFile::get_closest_files(files.collect(), target, 5); if args.list_all {
files.for_each(|f| println!("{}", f.canonicalize().unwrap().to_string_lossy()));
return ();
}
let closest_files = TodoFile::get_closest_files(files.collect(), target, args.number);
if args.list { if args.list {
closest_files closest_files
.into_iter() .into_iter()