diff options
| author | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-07-24 17:56:36 +0200 |
|---|---|---|
| committer | Benedikt Peetz <benedikt.peetz@b-peetz.de> | 2026-07-24 17:56:36 +0200 |
| commit | 9cdc575666faad4c162f4b4cf519bfdd1fd528dc (patch) | |
| tree | 9287963ad11e237ca74edbd54161c03f3309927b /crates/turtle/src/history | |
| parent | chore: Last big refactoring (diff) | |
| download | atuin-9cdc575666faad4c162f4b4cf519bfdd1fd528dc.zip | |
feat: Finalize design for fish-shell integration
Diffstat (limited to 'crates/turtle/src/history')
| -rw-r--r-- | crates/turtle/src/history/builder.rs | 11 | ||||
| -rw-r--r-- | crates/turtle/src/history/mod.rs | 17 |
2 files changed, 21 insertions, 7 deletions
diff --git a/crates/turtle/src/history/builder.rs b/crates/turtle/src/history/builder.rs index 08d26f7f..57970301 100644 --- a/crates/turtle/src/history/builder.rs +++ b/crates/turtle/src/history/builder.rs @@ -1,3 +1,5 @@ +use std::time::Duration; + use typed_builder::TypedBuilder; use super::History; @@ -12,7 +14,7 @@ pub struct HistoryFromDb { command: String, cwd: String, exit: i64, - duration: i64, + duration: Duration, session: String, hostname: String, author: String, @@ -48,14 +50,19 @@ pub struct HistoryDaemonCapture { timestamp: time::OffsetDateTime, #[builder(setter(into))] command: String, + #[builder(setter(into))] cwd: String, + #[builder(setter(into))] session: String, + #[builder(setter(into))] hostname: String, + #[builder(default, setter(strip_option, into))] author: Option<String>, + #[builder(default, setter(strip_option, into))] intent: Option<String>, } @@ -67,7 +74,7 @@ impl From<HistoryDaemonCapture> for History { captured.command, captured.cwd, -1, - -1, + Duration::from_nanos(0), captured.session, captured.hostname, captured.author, diff --git a/crates/turtle/src/history/mod.rs b/crates/turtle/src/history/mod.rs index 27755bbe..3617bc54 100644 --- a/crates/turtle/src/history/mod.rs +++ b/crates/turtle/src/history/mod.rs @@ -2,6 +2,8 @@ use core::fmt::Formatter; use regex::RegexSet; use std::env; use std::fmt::Display; +use std::time::Duration; +use uuid::Uuid; use turtle_common::utils::uuid_v7; @@ -15,8 +17,8 @@ mod secrets; const HISTORY_AUTHOR_ENV: &str = "ATUIN_HISTORY_AUTHOR"; const HISTORY_INTENT_ENV: &str = "ATUIN_HISTORY_INTENT"; -#[derive(Clone, Debug, Eq, PartialEq, Hash)] -pub struct HistoryId(pub String); +#[derive(Clone, Debug, Eq, PartialEq, Hash, Copy)] +pub struct HistoryId(Uuid); impl Display for HistoryId { fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { @@ -26,7 +28,12 @@ impl Display for HistoryId { impl From<String> for HistoryId { fn from(s: String) -> Self { - Self(s) + Self(Uuid::parse_str(&s).expect("should be a valid uuid")) + } +} +impl From<&str> for HistoryId { + fn from(s: &str) -> Self { + Self(Uuid::parse_str(s).expect("should be a valid uuid")) } } @@ -54,7 +61,7 @@ pub struct History { pub timestamp: OffsetDateTime, /// How long the command took to run. - pub duration: i64, + pub duration: Duration, /// The exit code of the command. pub exit: i64, @@ -106,7 +113,7 @@ impl History { command: String, cwd: String, exit: i64, - duration: i64, + duration: Duration, session: String, hostname: String, author: Option<String>, |
