From fb6290d73a5df1ce34c87c07e1e8da23a45641c4 Mon Sep 17 00:00:00 2001 From: edef Date: Tue, 3 May 2022 00:33:45 +0000 Subject: ripple/fossil/add: only accept a single directory arg This changes it from building an implicit top-level directory containing all its args, to simply accepting a directory. Change-Id: Iaf00e07d8568367b9eb27f365e8a2eaac3576974 --- ripple/fossil/src/bin/add.rs | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) (limited to 'ripple/fossil/src') diff --git a/ripple/fossil/src/bin/add.rs b/ripple/fossil/src/bin/add.rs index 84e67e2..ba51cd6 100644 --- a/ripple/fossil/src/bin/add.rs +++ b/ripple/fossil/src/bin/add.rs @@ -3,18 +3,16 @@ use { clap::StructOpt, - fossil::Directory, prost::Message, std::{ io::{self, Write}, - path::{Path, PathBuf}, + path::PathBuf, }, }; #[derive(clap::Parser)] struct Args { - #[clap(name = "PATH")] - paths: Vec, + dir: PathBuf, #[clap(long, default_value = "fossil.db")] store: PathBuf, } @@ -23,18 +21,7 @@ fn main() { let args = Args::parse(); let store = fossil::Store::open(args.store).unwrap(); - let mut root = Directory::new(); - - for name in args.paths { - let path = Path::new(&name); - let name = path - .file_name() - .and_then(|s| s.to_str()) - .expect("invalid path") - .to_owned(); - - root.children.insert(name, store.add_path(path)); - } + let root = store.add_directory(args.dir); let mut stdout = io::stdout(); stdout.write_all(&root.into_pb().encode_to_vec()).unwrap(); -- cgit 1.4.1