aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorprintfn <1643883+printfn@users.noreply.github.com>2025-04-29 02:17:13 +1200
committerGitHub <noreply@github.com>2025-04-28 15:17:13 +0100
commitdc7082d6812fc52b0e6fb2dc72141bfb4bfef400 (patch)
tree5f85877b3a2334293108034dcac4d266d73e4e2f
parentchore(deps): bump unicode-width from 0.1.14 to 0.2.0 (#2722) (diff)
downloadatuin-dc7082d6812fc52b0e6fb2dc72141bfb4bfef400.zip
feat: sort `atuin store status` output (#2719)
Co-authored-by: printfn <printfn@users.noreply.github.com>
-rw-r--r--crates/atuin/src/command/client/store.rs14
1 files changed, 9 insertions, 5 deletions
diff --git a/crates/atuin/src/command/client/store.rs b/crates/atuin/src/command/client/store.rs
index 198cbd69..63029ee1 100644
--- a/crates/atuin/src/command/client/store.rs
+++ b/crates/atuin/src/command/client/store.rs
@@ -6,7 +6,8 @@ use atuin_client::{
record::{sqlite_store::SqliteStore, store::Store},
settings::Settings,
};
-use time::OffsetDateTime;
+use itertools::Itertools;
+use time::{OffsetDateTime, UtcOffset};
#[cfg(feature = "sync")]
mod push;
@@ -70,11 +71,12 @@ impl Cmd {
pub async fn status(&self, store: SqliteStore) -> Result<()> {
let host_id = Settings::host_id().expect("failed to get host_id");
+ let offset = UtcOffset::current_local_offset().unwrap_or(UtcOffset::UTC);
let status = store.status().await?;
// TODO: should probs build some data structure and then pretty-print it or smth
- for (host, st) in &status.hosts {
+ for (host, st) in status.hosts.iter().sorted_by_key(|(h, _)| *h) {
let host_string = if host == &host_id {
format!("host: {} <- CURRENT HOST", host.0.as_hyphenated())
} else {
@@ -83,7 +85,7 @@ impl Cmd {
println!("{host_string}");
- for (tag, idx) in st {
+ for (tag, idx) in st.iter().sorted_by_key(|(tag, _)| *tag) {
println!("\tstore: {tag}");
let first = store.first(*host, tag).await?;
@@ -95,7 +97,8 @@ impl Cmd {
println!("\t\tfirst: {}", first.id.0.as_hyphenated());
let time =
- OffsetDateTime::from_unix_timestamp_nanos(i128::from(first.timestamp))?;
+ OffsetDateTime::from_unix_timestamp_nanos(i128::from(first.timestamp))?
+ .to_offset(offset);
println!("\t\t\tcreated: {time}");
}
@@ -103,7 +106,8 @@ impl Cmd {
println!("\t\tlast: {}", last.id.0.as_hyphenated());
let time =
- OffsetDateTime::from_unix_timestamp_nanos(i128::from(last.timestamp))?;
+ OffsetDateTime::from_unix_timestamp_nanos(i128::from(last.timestamp))?
+ .to_offset(offset);
println!("\t\t\tcreated: {time}");
}
}