summaryrefslogtreecommitdiff
path: root/src/cmd/list_backup_versions.rs
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-03-22 17:10:02 +0000
committerLars Wirzenius <liw@liw.fi>2022-03-22 17:10:02 +0000
commit4a9b26903d48d622f7f2a01eb54eec88e92da868 (patch)
tree6d1a5f4fa835cd217d256ac3cdd5baec5902a2af /src/cmd/list_backup_versions.rs
parent7ae1f33ad0cd0df227e83997268ce2f3540db8d7 (diff)
parent018fcd28c8dbf84d34cc370496139f678664ca8f (diff)
downloadobnam2-4a9b26903d48d622f7f2a01eb54eec88e92da868.tar.gz
Merge branch 'liw/schema-refactor' into 'main'
add backup database schema to evolove; break server database Closes #194 and #192 See merge request obnam/obnam!222
Diffstat (limited to 'src/cmd/list_backup_versions.rs')
-rw-r--r--src/cmd/list_backup_versions.rs31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/cmd/list_backup_versions.rs b/src/cmd/list_backup_versions.rs
new file mode 100644
index 0000000..859d91c
--- /dev/null
+++ b/src/cmd/list_backup_versions.rs
@@ -0,0 +1,31 @@
+//! The `backup` subcommand.
+
+use crate::config::ClientConfig;
+use crate::dbgen::{schema_version, DEFAULT_SCHEMA_MAJOR, SCHEMA_MAJORS};
+use crate::error::ObnamError;
+
+use structopt::StructOpt;
+
+/// List supported backup schema versions.
+#[derive(Debug, StructOpt)]
+pub struct ListSchemaVersions {
+ /// List only the default version.
+ #[structopt(long)]
+ default_only: bool,
+}
+
+impl ListSchemaVersions {
+ /// Run the command.
+ pub fn run(&self, _config: &ClientConfig) -> Result<(), ObnamError> {
+ if self.default_only {
+ let schema = schema_version(DEFAULT_SCHEMA_MAJOR)?;
+ println!("{}", schema);
+ } else {
+ for major in SCHEMA_MAJORS {
+ let schema = schema_version(*major)?;
+ println!("{}", schema);
+ }
+ }
+ Ok(())
+ }
+}