blob: 333a0fad4e43eff228e6a5d88e37d8aa426257fc (
plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
use std::path::PathBuf;
use crate::{SHA, VERSION};
use atuin_client::{api_client, database::Database, settings::Settings};
use colored::Colorize;
use eyre::Result;
pub async fn run(settings: &Settings, db: &impl Database) -> Result<()> {
let session_path = settings.session_path.as_str();
if !PathBuf::from(session_path).exists() {
println!("You are not logged in to a sync server - cannot show sync status");
return Ok(());
}
let client = api_client::Client::new(
&settings.sync_address,
&settings.session_token,
settings.network_connect_timeout,
settings.network_timeout,
)?;
let status = client.status().await?;
let last_sync = Settings::last_sync()?;
let local_count = db.history_count(false).await?;
let deleted_count = db.history_count(true).await? - local_count;
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}");
}
if !settings.sync.records {
println!("History count: {local_count}");
println!("Deleted history count: {deleted_count}\n");
}
if settings.auto_sync {
println!("{}", "[Remote]".green());
println!("Address: {}", settings.sync_address);
println!("Username: {}", status.username);
}
Ok(())
}
|