aboutsummaryrefslogtreecommitdiffstats
path: root/crates/atuin-client/src/history/builder.rs
diff options
context:
space:
mode:
authorEllie Huxtable <ellie@elliehuxtable.com>2024-05-08 12:09:04 +0100
committerGitHub <noreply@github.com>2024-05-08 12:09:04 +0100
commitbce0faa1c2dc221b0ff77d2cd647bfb2a48ffa7e (patch)
tree4d66bd95b151d3bab4cabf8799805c739f608bc4 /crates/atuin-client/src/history/builder.rs
parentfix(config): add quotes for strategy value in comment (#1993) (diff)
downloadatuin-bce0faa1c2dc221b0ff77d2cd647bfb2a48ffa7e.zip
feat: add background daemon (#2006)
* init daemon crate * wip * minimal functioning daemon, needs cleanup for sure * better errors * add signal cleanup * logging * things * add sync worker * move daemon crate * 30s -> 5mins * make clippy happy * fix stuff maybe? * fmt * trim packages * rate limit fix * more protoc huh * this makes no sense, why linux why * can it install literally just curl * windows in ci is slow, and all the newer things will not work there. disable the daemon feature and it will build * add daemon feature * maybe this * ok wut where is protoc * try setting protoc * hm * try copying protoc * remove optional * add cross config * idk nix * does nix want this? * some random pkg I found does this * uh oh * hack, be gone! * update contributing
Diffstat (limited to 'crates/atuin-client/src/history/builder.rs')
-rw-r--r--crates/atuin-client/src/history/builder.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/crates/atuin-client/src/history/builder.rs b/crates/atuin-client/src/history/builder.rs
index 4e69cf66..2b28339f 100644
--- a/crates/atuin-client/src/history/builder.rs
+++ b/crates/atuin-client/src/history/builder.rs
@@ -97,3 +97,36 @@ impl From<HistoryFromDb> for History {
}
}
}
+
+/// Builder for a history entry that is captured via hook and sent to the daemon
+///
+/// This builder is similar to Capture, but we just require more information up front.
+/// For the old setup, we could just rely on History::new to read some of the missing
+/// data. This is no longer the case.
+#[derive(Debug, Clone, TypedBuilder)]
+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,
+}
+
+impl From<HistoryDaemonCapture> for History {
+ fn from(captured: HistoryDaemonCapture) -> Self {
+ History::new(
+ captured.timestamp,
+ captured.command,
+ captured.cwd,
+ -1,
+ -1,
+ Some(captured.session),
+ Some(captured.hostname),
+ None,
+ )
+ }
+}