Private
Public Access
1
0

daemon: scaffolding for settings / sync

This commit is contained in:
2025-04-25 18:02:54 -07:00
parent 0c6b55fa38
commit fe32efef2c
10 changed files with 204 additions and 45 deletions

View File

@@ -10,10 +10,16 @@ mod dbus_interface {
include!(concat!(env!("OUT_DIR"), "/kordophone-client.rs"));
}
use dbus_interface::NetBuzzertKordophoneServer as KordophoneServer;
use dbus_interface::NetBuzzertKordophoneRepository as KordophoneRepository;
#[derive(Subcommand)]
pub enum Commands {
/// Gets all known conversations.
Conversations,
/// Runs a sync operation.
Sync,
/// Prints the server Kordophone version.
Version,
}
@@ -23,6 +29,8 @@ impl Commands {
let mut client = DaemonCli::new()?;
match cmd {
Commands::Version => client.print_version().await,
Commands::Conversations => client.print_conversations().await,
Commands::Sync => client.sync_conversations().await,
}
}
}
@@ -43,8 +51,20 @@ impl DaemonCli {
}
pub async fn print_version(&mut self) -> Result<()> {
let version = KordophoneServer::get_version(&self.proxy())?;
let version = KordophoneRepository::get_version(&self.proxy())?;
println!("Server version: {}", version);
Ok(())
}
pub async fn print_conversations(&mut self) -> Result<()> {
let conversations = KordophoneRepository::get_conversations(&self.proxy())?;
println!("Conversations: {:?}", conversations);
Ok(())
}
pub async fn sync_conversations(&mut self) -> Result<()> {
let success = KordophoneRepository::sync_all_conversations(&self.proxy())?;
println!("Synced conversations: {}", success);
Ok(())
}
}

View File

@@ -48,6 +48,6 @@ async fn main() {
let cli = Cli::parse();
run_command(cli.command).await
.map_err(|e| log::error!("Error: {}", e))
.map_err(|e| println!("Error: {}", e))
.err();
}