aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/command/client/sync
diff options
context:
space:
mode:
Diffstat (limited to 'crates/turtle/src/command/client/sync')
-rw-r--r--crates/turtle/src/command/client/sync/status.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/crates/turtle/src/command/client/sync/status.rs b/crates/turtle/src/command/client/sync/status.rs
new file mode 100644
index 00000000..00088b59
--- /dev/null
+++ b/crates/turtle/src/command/client/sync/status.rs
@@ -0,0 +1,37 @@
+use crate::{SHA, VERSION};
+use crate::atuin_client::{api_client, settings::Settings};
+use colored::Colorize;
+use eyre::{Result, bail};
+
+pub async fn run(settings: &Settings) -> Result<()> {
+ if !settings.logged_in().await? {
+ bail!("You are not logged in to a sync server - cannot show sync status");
+ }
+
+ let client = api_client::Client::new(
+ &settings.sync_address,
+ settings.sync_auth_token().await?,
+ settings.network_connect_timeout,
+ settings.network_timeout,
+ )?;
+
+ let me = client.me().await?;
+ let last_sync = Settings::last_sync().await?;
+
+ println!("Atuin v{VERSION} - Build rev {SHA}\n");
+
+ println!("{}", "[Local]".green());
+
+ if settings.auto_sync {
+ println!("Sync frequency: {}", settings.sync_frequency);
+ println!("Last sync: {}", last_sync.to_offset(settings.timezone.0));
+ }
+
+ if settings.auto_sync {
+ println!("{}", "[Remote]".green());
+ println!("Address: {}", settings.sync_address);
+ println!("Username: {}", me.username);
+ }
+
+ Ok(())
+}