diff options
author | metamuffin <metamuffin@disroot.org> | 2024-06-14 03:57:14 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2024-06-14 03:57:14 +0200 |
commit | e34da6ca957ec813a361cbcaf0dc89e953af6db1 (patch) | |
tree | 08f15f33502a961382fcb3aa2933ab5982b7cc36 /src/main.rs | |
parent | 956b172ddbff214d055127fb89905f0057492a26 (diff) | |
download | online-offsite-backup-e34da6ca957ec813a361cbcaf0dc89e953af6db1.tar online-offsite-backup-e34da6ca957ec813a361cbcaf0dc89e953af6db1.tar.bz2 online-offsite-backup-e34da6ca957ec813a361cbcaf0dc89e953af6db1.tar.zst |
list works
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(()) |