aboutsummaryrefslogtreecommitdiffstats
path: root/crates/turtle/src/command/client/sync/status.rs
blob: e75171eb4bf0efdf4b14f04383cf24222b646f99 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
use crate::atuin_client::settings::Settings;
use crate::{SHA, VERSION};
use colored::Colorize;
use eyre::{Result, bail};

pub(crate) async fn run(settings: &Settings) -> Result<()> {
    if let Some(me) = settings.sync.user_id()? {
        let last_sync = Settings::last_sync().await?;

        println!("Atuin v{VERSION} - Build rev {SHA}\n");

        println!("{}", "[Local]".green());
        println!("Sync frequency: {}", settings.sync.frequency);
        println!("Last sync: {}", last_sync.to_offset(settings.timezone.0));
        println!("Auto sync: {}", settings.sync.auto);

        println!("{}", "[Remote]".green());
        println!("Address: {}", settings.sync.address);
        println!("User id: {}", me);
    } else {
        bail!("You are not logged in to a sync server - cannot show sync status");
    }

    Ok(())
}