diff options
| author | Ellie Huxtable <ellie@elliehuxtable.com> | 2023-03-30 06:45:49 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-03-30 06:45:49 +0100 |
| commit | 0d16a113c5fc9da7bb75f8c771714f4e00449f19 (patch) | |
| tree | 87e7bb841f5e9cc2ffa0dd3d5492c0a4648b4db7 /src/command/client/sync/status.rs | |
| parent | Update `atuin search` docs (#828) (diff) | |
| download | atuin-0d16a113c5fc9da7bb75f8c771714f4e00449f19.zip | |
Add `atuin status` (#830)
Useful for debugging, checking the state of things, and for if you
forget your username!
Diffstat (limited to '')
| -rw-r--r-- | src/command/client/sync/status.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/command/client/sync/status.rs b/src/command/client/sync/status.rs new file mode 100644 index 00000000..b3e73e8e --- /dev/null +++ b/src/command/client/sync/status.rs @@ -0,0 +1,35 @@ +use atuin_client::{ + api_client, database::Database, encryption::load_encoded_key, settings::Settings, +}; +use colored::Colorize; +use eyre::Result; + +pub async fn run(settings: &Settings, db: &impl Database) -> Result<()> { + let client = api_client::Client::new( + &settings.sync_address, + &settings.session_token, + load_encoded_key(settings)?, + )?; + + let status = client.status().await?; + let last_sync = Settings::last_sync()?; + let local_count = db.history_count().await?; + + println!("{}", "[Local]".green()); + + if settings.auto_sync { + println!("Sync frequency: {}", settings.sync_frequency); + println!("Last sync: {last_sync}"); + } + + println!("History count: {local_count}\n"); + + if settings.auto_sync { + println!("{}", "[Remote]".green()); + println!("Address: {}", settings.sync_address); + println!("Username: {}", status.username); + println!("History count: {}", status.count); + } + + Ok(()) +} |
