diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-03-20 07:53:06 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-03-20 10:53:46 +0200 |
commit | 2938409cff80d66b4b9f672ab48d2d93822c4aa2 (patch) | |
tree | ddd2d24aa6399a97d877174fd01e3b69df57b732 /src/cmd/list_backup_versions.rs | |
parent | f309f897a06f2870aac386f6218b939e86ed89ba (diff) | |
download | obnam2-2938409cff80d66b4b9f672ab48d2d93822c4aa2.tar.gz |
feat: add subcommands inspect, list-backup-versions
Sponsored-by: author
Diffstat (limited to 'src/cmd/list_backup_versions.rs')
-rw-r--r-- | src/cmd/list_backup_versions.rs | 31 |
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(()) + } +} |