aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-client/src/import/zsh.rs
diff options
context:
space:
mode:
authorVlad Stepanov <8uk.8ak@gmail.com>2023-06-15 14:29:40 +0400
committerGitHub <noreply@github.com>2023-06-15 10:29:40 +0000
commit4077c33adfdacaf0ed68657a1955a7b69a78d373 (patch)
tree432d5c23992388a6c1bd4b11d41785ea00d56905 /atuin-client/src/import/zsh.rs
parentAdd namespaces to kv store (#1052) (diff)
downloadatuin-4077c33adfdacaf0ed68657a1955a7b69a78d373.zip
Builder interface for History objects (#933)
* [feature] store env variables in History records WIP: remove `HistoryWithoutDelete`, add some docstrings, tests * Create History objects through builders. Assure in compile-time that all required fields are set for the given construction scenario * (from #882) split Cmd::run into subfns * Update `History` doc * remove rmp-serde from history * update warning --------- Co-authored-by: Conrad Ludgate <conrad.ludgate@truelayer.com>
Diffstat (limited to 'atuin-client/src/import/zsh.rs')
-rw-r--r--atuin-client/src/import/zsh.rs35
1 files changed, 13 insertions, 22 deletions
diff --git a/atuin-client/src/import/zsh.rs b/atuin-client/src/import/zsh.rs
index 19917daf..e98819e2 100644
--- a/atuin-client/src/import/zsh.rs
+++ b/atuin-client/src/import/zsh.rs
@@ -82,17 +82,12 @@ impl Importer for Zsh {
let offset = chrono::Duration::seconds(counter);
counter += 1;
- h.push(History::new(
- now - offset, // preserve ordering
- command.trim_end().to_string(),
- String::from("unknown"),
- -1,
- -1,
- None,
- None,
- None,
- ))
- .await?;
+ let imported = History::import()
+ // preserve ordering
+ .timestamp(now - offset)
+ .command(command.trim_end().to_string());
+
+ h.push(imported.build().into()).await?;
}
}
}
@@ -113,19 +108,15 @@ fn parse_extended(line: &str, counter: i64) -> History {
let time = Utc.timestamp(time, 0);
let time = time + offset;
+ // use nanos, because why the hell not? we won't display them.
let duration = duration.parse::<i64>().map_or(-1, |t| t * 1_000_000_000);
- // use nanos, because why the hell not? we won't display them.
- History::new(
- time,
- command.trim_end().to_string(),
- String::from("unknown"),
- 0, // assume 0, we have no way of knowing :(
- duration,
- None,
- None,
- None,
- )
+ let imported = History::import()
+ .timestamp(time)
+ .command(command.trim_end().to_string())
+ .duration(duration);
+
+ imported.build().into()
}
#[cfg(test)]