aboutsummaryrefslogtreecommitdiffstats
path: root/src/command/mod.rs
diff options
context:
space:
mode:
authorEllie Huxtable <e@elm.sh>2021-04-13 19:14:07 +0100
committerGitHub <noreply@github.com>2021-04-13 19:14:07 +0100
commit5751463942cc91f1f1ffaf6e2ac633d7a0085f25 (patch)
treef7b5b9a4702c4c3ef29aa60d36612f61ffeae052 /src/command/mod.rs
parentUpdate config (diff)
downloadatuin-5751463942cc91f1f1ffaf6e2ac633d7a0085f25.zip
Add history sync, resolves #13 (#31)
* Add encryption * Add login and register command * Add count endpoint * Write initial sync push * Add single sync command Confirmed working for one client only * Automatically sync on a configurable frequency * Add key command, key arg to login * Only load session if it exists * Use sync and history timestamps for download * Bind other key code Seems like some systems have this code for up arrow? I'm not sure why, and it's not an easy one to google. * Simplify upload * Try and fix download sync loop * Change sync order to avoid uploading what we just downloaded * Multiline import fix * Fix time parsing * Fix importing history with no time * Add hostname to sync * Use hostname to filter sync * Fixes * Add binding * Stuff from yesterday * Set cursor modes * Make clippy happy * Bump version
Diffstat (limited to 'src/command/mod.rs')
-rw-r--r--src/command/mod.rs34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/command/mod.rs b/src/command/mod.rs
index a5ea0228..eeb11a87 100644
--- a/src/command/mod.rs
+++ b/src/command/mod.rs
@@ -9,9 +9,12 @@ mod event;
mod history;
mod import;
mod init;
+mod login;
+mod register;
mod search;
mod server;
mod stats;
+mod sync;
#[derive(StructOpt)]
pub enum AtuinCmd {
@@ -38,6 +41,21 @@ pub enum AtuinCmd {
#[structopt(about = "interactive history search")]
Search { query: Vec<String> },
+
+ #[structopt(about = "sync with the configured server")]
+ Sync {
+ #[structopt(long, short, about = "force re-download everything")]
+ force: bool,
+ },
+
+ #[structopt(about = "login to the configured server")]
+ Login(login::Cmd),
+
+ #[structopt(about = "register with the configured server")]
+ Register(register::Cmd),
+
+ #[structopt(about = "print the encryption key for transfer to another machine")]
+ Key,
}
pub fn uuid_v4() -> String {
@@ -47,13 +65,27 @@ pub fn uuid_v4() -> String {
impl AtuinCmd {
pub fn run(self, db: &mut impl Database, settings: &Settings) -> Result<()> {
match self {
- Self::History(history) => history.run(db),
+ Self::History(history) => history.run(settings, db),
Self::Import(import) => import.run(db),
Self::Server(server) => server.run(settings),
Self::Stats(stats) => stats.run(db, settings),
Self::Init => init::init(),
Self::Search { query } => search::run(&query, db),
+ Self::Sync { force } => sync::run(settings, force, db),
+ Self::Login(l) => l.run(settings),
+ Self::Register(r) => register::run(
+ settings,
+ r.username.as_str(),
+ r.email.as_str(),
+ r.password.as_str(),
+ ),
+ Self::Key => {
+ let key = std::fs::read(settings.local.key_path.as_str())?;
+ println!("{}", base64::encode(key));
+ Ok(())
+ }
+
Self::Uuid => {
println!("{}", uuid_v4());
Ok(())