diff options
author | Lars Wirzenius <liw@liw.fi> | 2020-11-09 10:02:58 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2020-11-09 10:02:58 +0200 |
commit | f46e19447a1d4adbdebd3e9e448e2445327b40f1 (patch) | |
tree | d0c4a3872f8cc0585a6bde6b846e920d62f57d3a /src | |
parent | 482fc0dcb42a02e44fbdf3bb5e42ee8639b895d5 (diff) | |
download | obnam2-f46e19447a1d4adbdebd3e9e448e2445327b40f1.tar.gz |
start on obnam-list
Diffstat (limited to 'src')
-rw-r--r-- | src/bin/obnam-list.rs | 27 | ||||
-rw-r--r-- | src/bin/obnam-server.rs | 6 | ||||
-rw-r--r-- | src/client.rs | 4 |
3 files changed, 36 insertions, 1 deletions
diff --git a/src/bin/obnam-list.rs b/src/bin/obnam-list.rs new file mode 100644 index 0000000..18c49f1 --- /dev/null +++ b/src/bin/obnam-list.rs @@ -0,0 +1,27 @@ +use log::{debug, info}; +use obnam::client::{BackupClient, ClientConfig}; +use std::path::PathBuf; +use structopt::StructOpt; + +fn main() -> anyhow::Result<()> { + pretty_env_logger::init(); + + let opt = Opt::from_args(); + info!("obnam-list starts"); + debug!("opt: {:?}", opt); + let config = ClientConfig::read_config(&opt.config)?; + let client = BackupClient::new(&config.server_name, config.server_port)?; + + for gen_id in client.list_generations()? { + println!("{}", gen_id); + } + + Ok(()) +} + +#[derive(Debug, StructOpt)] +#[structopt(name = "obnam-backup", about = "Simplistic backup client")] +struct Opt { + #[structopt(parse(from_os_str))] + config: PathBuf, +} diff --git a/src/bin/obnam-server.rs b/src/bin/obnam-server.rs index cc21855..4e53953 100644 --- a/src/bin/obnam-server.rs +++ b/src/bin/obnam-server.rs @@ -195,7 +195,11 @@ pub async fn search_chunks( error!("search has more than one key to search for"); return Ok(ChunkResult::BadRequest); } - index.find(&key, &value) + if key == "generation" && value == "true" { + index.find_generations() + } else { + index.find(&key, &value) + } } else { error!("search has no key to search for"); return Ok(ChunkResult::BadRequest); diff --git a/src/client.rs b/src/client.rs index e7b5a3e..5402588 100644 --- a/src/client.rs +++ b/src/client.rs @@ -163,4 +163,8 @@ impl BackupClient { Ok(chunk_ids) } + + pub fn list_generations(&self) -> anyhow::Result<Vec<ChunkId>> { + Ok(vec![]) + } } |