mirror of
https://github.com/icewind1991/zox
synced 2026-06-03 18:34:07 +02:00
print history when no arguments are provided
This commit is contained in:
parent
73c7464c26
commit
982966d023
1 changed files with 17 additions and 0 deletions
17
src/main.rs
17
src/main.rs
|
|
@ -1,6 +1,7 @@
|
|||
use main_error::MainError;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::cmp::Ordering;
|
||||
use std::io::{stdout, Write};
|
||||
use std::time::{SystemTime, UNIX_EPOCH};
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize)]
|
||||
|
|
@ -150,6 +151,22 @@ fn main() -> Result<(), MainError> {
|
|||
return Ok(());
|
||||
}
|
||||
|
||||
if args.filter.is_empty() {
|
||||
let mut history: Vec<_> = history_result
|
||||
.map(|history| history.collect())
|
||||
.unwrap_or_default();
|
||||
|
||||
history.sort_by(|a, b| b.rank.partial_cmp(&a.rank).unwrap());
|
||||
|
||||
let stdout = stdout();
|
||||
let mut handle = stdout.lock();
|
||||
for item in history {
|
||||
let _ = writeln!(&mut handle, "{}|{}|{}", item.path, item.rank, item.time);
|
||||
}
|
||||
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Ok(history) = history_result {
|
||||
let matches = history.filter(|item| item.matches(&args.filter));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue