aboutsummaryrefslogtreecommitdiffstats
path: root/atuin-client/src/import/nu_histdb.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/nu_histdb.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/nu_histdb.rs')
-rw-r--r--atuin-client/src/import/nu_histdb.rs23
1 files changed, 13 insertions, 10 deletions
diff --git a/atuin-client/src/import/nu_histdb.rs b/atuin-client/src/import/nu_histdb.rs
index 0fb5192e..34568d80 100644
--- a/atuin-client/src/import/nu_histdb.rs
+++ b/atuin-client/src/import/nu_histdb.rs
@@ -30,16 +30,19 @@ impl From<HistDbEntry> for History {
fn from(histdb_item: HistDbEntry) -> Self {
let ts_secs = histdb_item.start_timestamp / 1000;
let ts_ns = (histdb_item.start_timestamp % 1000) * 1_000_000;
- History::new(
- DateTime::from_utc(NaiveDateTime::from_timestamp(ts_secs, ts_ns as u32), Utc),
- String::from_utf8(histdb_item.command_line).unwrap(),
- String::from_utf8(histdb_item.cwd).unwrap(),
- histdb_item.exit_status,
- histdb_item.duration_ms,
- Some(format!("{:x}", histdb_item.session_id)),
- Some(String::from_utf8(histdb_item.hostname).unwrap()),
- None,
- )
+ let imported = History::import()
+ .timestamp(DateTime::from_utc(
+ NaiveDateTime::from_timestamp(ts_secs, ts_ns as u32),
+ Utc,
+ ))
+ .command(String::from_utf8(histdb_item.command_line).unwrap())
+ .cwd(String::from_utf8(histdb_item.cwd).unwrap())
+ .exit(histdb_item.exit_status)
+ .duration(histdb_item.duration_ms)
+ .session(format!("{:x}", histdb_item.session_id))
+ .hostname(String::from_utf8(histdb_item.hostname).unwrap());
+
+ imported.build().into()
}
}