diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/src/main.rs b/src/main.rs index 243c621..c72aad7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,8 +1,10 @@ -#![feature(iterator_try_collect)] -#![feature(never_type)] +#![feature(iterator_try_collect, never_type)] +pub mod client; pub mod server; +use anyhow::Result; use clap::{Parser, Subcommand}; +use client::Client; use serde::Deserialize; use server::server; use std::{fs::read_to_string, net::SocketAddr, path::PathBuf}; @@ -19,8 +21,17 @@ struct Args { #[derive(Subcommand)] enum Action { Daemon, - Restore { id: String, destination: PathBuf }, - Backup { path: PathBuf }, + List { + peer: Option<String>, + }, + Restore { + peer: String, + id: String, + destination: PathBuf, + }, + Backup { + path: PathBuf, + }, } #[derive(Deserialize)] @@ -53,7 +64,7 @@ pub struct StorageConfig { download_speed: usize, } -fn main() -> anyhow::Result<()> { +fn main() -> Result<()> { env_logger::init_from_env("LOG"); let args = Args::parse(); @@ -62,7 +73,29 @@ fn main() -> anyhow::Result<()> { match args.action { Action::Daemon => server(config.into())?, - Action::Restore { id, destination } => todo!(), + Action::List { peer } => { + let peers = config.peer.iter().filter(|p| { + if let Some(pn) = &peer { + pn == &p.name + } else { + true + } + }); + + for p in peers { + println!("peer {:?}", p.name); + let mut client = Client::new(p.address, &p.shared_secret)?; + for (mtime, size, serial) in client.list()? { + println!("\tserial={serial} mtime={mtime} size={size}") + } + client.quit()?; + } + } + Action::Restore { + id, + destination, + peer, + } => todo!(), Action::Backup { path } => todo!(), } Ok(()) |