aboutsummaryrefslogtreecommitdiffstats
path: root/src/local/history.rs
diff options
context:
space:
mode:
authorEllie Huxtable <e@elm.sh>2021-04-20 21:53:07 +0100
committerGitHub <noreply@github.com>2021-04-20 20:53:07 +0000
commita21737e2b7f8d1e426726bdd7536033f299d476a (patch)
treee940afdff9c145d25d9a2895fd44a77d70719a2e /src/local/history.rs
parentSwitch to Warp + SQLx, use async, switch to Rust stable (#36) (diff)
downloadatuin-a21737e2b7f8d1e426726bdd7536033f299d476a.zip
Use cargo workspaces (#37)
* Switch to Cargo workspaces Breaking things into "client", "server" and "common" makes managing the codebase much easier! client - anything running on a user's machine for adding history server - handles storing/syncing history and running a HTTP server common - request/response API definitions, common utils, etc * Update dockerfile
Diffstat (limited to 'src/local/history.rs')
-rw-r--r--src/local/history.rs66
1 files changed, 0 insertions, 66 deletions
diff --git a/src/local/history.rs b/src/local/history.rs
deleted file mode 100644
index 1712f8b9..00000000
--- a/src/local/history.rs
+++ /dev/null
@@ -1,66 +0,0 @@
-use std::env;
-use std::hash::{Hash, Hasher};
-
-use chrono::Utc;
-
-use crate::command::uuid_v4;
-
-// Any new fields MUST be Optional<>!
-#[derive(Debug, Clone, Serialize, Deserialize)]
-pub struct History {
- pub id: String,
- pub timestamp: chrono::DateTime<Utc>,
- pub duration: i64,
- pub exit: i64,
- pub command: String,
- pub cwd: String,
- pub session: String,
- pub hostname: String,
-}
-
-impl History {
- pub fn new(
- timestamp: chrono::DateTime<Utc>,
- command: String,
- cwd: String,
- exit: i64,
- duration: i64,
- session: Option<String>,
- hostname: Option<String>,
- ) -> Self {
- let session = session
- .or_else(|| env::var("ATUIN_SESSION").ok())
- .unwrap_or_else(uuid_v4);
- let hostname =
- hostname.unwrap_or_else(|| format!("{}:{}", whoami::hostname(), whoami::username()));
-
- Self {
- id: uuid_v4(),
- timestamp,
- command,
- cwd,
- exit,
- duration,
- session,
- hostname,
- }
- }
-}
-
-impl PartialEq for History {
- // for the sakes of listing unique history only, we do not care about
- // anything else
- // obviously this does not refer to the *same* item of history, but when
- // we only render the command, it looks the same
- fn eq(&self, other: &Self) -> bool {
- self.command == other.command
- }
-}
-
-impl Eq for History {}
-
-impl Hash for History {
- fn hash<H: Hasher>(&self, state: &mut H) {
- self.command.hash(state);
- }
-}