diff options
author | Vladislav Stepanov <8uk.8ak@gmail.com> | 2023-04-14 23:18:58 +0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-14 20:18:58 +0100 |
commit | c05d2850420a2c163b8f62c33a6cef7c0ae1ad8d (patch) | |
tree | 2c44a44eda7e76fa74e78ac1fd02f55c1ed4d804 /src/command/client/sync.rs | |
parent | 03dd3ddf8b8c0ad254850cd940728c888dd7a80c (diff) |
Workspace reorder (#868)
* Try different workspace structure
Move main crate (atuin) to be on the same level with other crates in
this workspace
* extract common dependencies to the workspace definition
* fix base64 v0.21 deprecation warning
* questionable: update deps & fix chrono deprecations
possible panic sites are unchanged, they're just more visible now
* Revert "questionable: update deps & fix chrono deprecations"
This reverts commit 993e60f8dea81a1625a04285a617959ad09a0866.
Diffstat (limited to 'src/command/client/sync.rs')
-rw-r--r-- | src/command/client/sync.rs | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/src/command/client/sync.rs b/src/command/client/sync.rs deleted file mode 100644 index 419177a50..000000000 --- a/src/command/client/sync.rs +++ /dev/null @@ -1,74 +0,0 @@ -use clap::Subcommand; -use eyre::{Result, WrapErr}; - -use atuin_client::{database::Database, settings::Settings}; - -mod login; -mod logout; -mod register; -mod status; - -#[derive(Subcommand)] -#[command(infer_subcommands = true)] -pub enum Cmd { - /// Sync with the configured server - Sync { - /// Force re-download everything - #[arg(long, short)] - force: bool, - }, - - /// Login to the configured server - Login(login::Cmd), - - /// Log out - Logout, - - /// Register with the configured server - Register(register::Cmd), - - /// Print the encryption key for transfer to another machine - Key { - /// Switch to base64 output of the key - #[arg(long)] - base64: bool, - }, - - Status, -} - -impl Cmd { - pub async fn run(self, settings: Settings, db: &mut impl Database) -> Result<()> { - match self { - Self::Sync { force } => run(&settings, force, db).await, - Self::Login(l) => l.run(&settings).await, - Self::Logout => logout::run(&settings), - Self::Register(r) => r.run(&settings).await, - Self::Status => status::run(&settings, db).await, - Self::Key { base64 } => { - use atuin_client::encryption::{encode_key, load_key}; - let key = load_key(&settings).wrap_err("could not load encryption key")?; - - if base64 { - let encode = encode_key(key).wrap_err("could not encode encryption key")?; - println!("{encode}"); - } else { - let mnemonic = bip39::Mnemonic::from_entropy(&key.0, bip39::Language::English) - .map_err(|_| eyre::eyre!("invalid key"))?; - println!("{mnemonic}"); - } - Ok(()) - } - } - } -} - -async fn run(settings: &Settings, force: bool, db: &mut impl Database) -> Result<()> { - atuin_client::sync::sync(settings, force, db).await?; - println!( - "Sync complete! {} items in database, force: {}", - db.history_count().await?, - force - ); - Ok(()) -} |