summaryrefslogtreecommitdiff
path: root/src/cmd/resolve.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/resolve.rs')
-rw-r--r--src/cmd/resolve.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/cmd/resolve.rs b/src/cmd/resolve.rs
new file mode 100644
index 0000000..a175655
--- /dev/null
+++ b/src/cmd/resolve.rs
@@ -0,0 +1,33 @@
+use crate::client::AsyncBackupClient;
+use crate::config::ClientConfig;
+use crate::error::ObnamError;
+use structopt::StructOpt;
+use tokio::runtime::Runtime;
+
+#[derive(Debug, StructOpt)]
+pub struct Resolve {
+ generation: String,
+}
+
+impl Resolve {
+ pub fn run(&self, config: &ClientConfig) -> Result<(), ObnamError> {
+ let rt = Runtime::new()?;
+ rt.block_on(self.run_async(config))
+ }
+
+ async fn run_async(&self, config: &ClientConfig) -> Result<(), ObnamError> {
+ let client = AsyncBackupClient::new(config)?;
+ let generations = client.list_generations().await?;
+
+ match generations.resolve(&self.generation) {
+ Err(err) => {
+ return Err(err.into());
+ }
+ Ok(old_id) => {
+ println!("{}", old_id);
+ }
+ };
+
+ Ok(())
+ }
+}