add option to backup a single device

This commit is contained in:
Robin Appelman 2024-06-25 21:14:24 +02:00
commit 0e7839f2b9

View file

@ -16,6 +16,7 @@ mod config;
#[derive(Debug, Parser)] #[derive(Debug, Parser)]
struct Args { struct Args {
config: PathBuf, config: PathBuf,
device: Option<String>,
} }
#[tokio::main] #[tokio::main]
@ -35,6 +36,7 @@ async fn main() -> Result<()> {
let devices = client.current_devices(); let devices = client.current_devices();
info!("found {} devices", devices.len()); info!("found {} devices", devices.len());
for device in devices { for device in devices {
if args.device.is_none() || args.device.as_deref() == Some(device.as_str()) {
let result = timeout( let result = timeout(
Duration::from_secs(120), Duration::from_secs(120),
download(&client, &device, &config.output.target, &device_password), download(&client, &device, &config.output.target, &device_password),
@ -47,6 +49,7 @@ async fn main() -> Result<()> {
error!(device = device, error = %e, "Failed to download config for {device}"); error!(device = device, error = %e, "Failed to download config for {device}");
} }
} }
}
Ok(()) Ok(())
} }