diff options
Diffstat (limited to 'ripple')
-rw-r--r-- | ripple/fossil/src/bin/add.rs | 19 |
1 files changed, 3 insertions, 16 deletions
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<PathBuf>, + 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(); |