summary refs log tree commit diff
path: root/ripple/fossil
diff options
context:
space:
mode:
authoredef <edef@unfathomable.blue>2022-05-03 00:08:20 +0000
committeredef <edef@unfathomable.blue>2022-05-03 00:08:20 +0000
commit5c544de74b64fc08029d09d12ecde894b5e78078 (patch)
treed06f977111d7db68b28f0af2b6294cf4a858e1b1 /ripple/fossil
parentbab70406b61e731dd79b8a12ce35772d0f46226b (diff)
ripple/fossil: use clap
This adds clap to all our binaries. Only add currently takes any args,
but previously, the others did not reject args as they should.

Change-Id: I6257fb3b218c624ee0124f6ed7313a579db88c4c
Diffstat (limited to 'ripple/fossil')
-rw-r--r--ripple/fossil/Cargo.toml1
-rw-r--r--ripple/fossil/src/bin/add.rs14
-rw-r--r--ripple/fossil/src/bin/extract.rs6
-rw-r--r--ripple/fossil/src/bin/mount.rs5
4 files changed, 23 insertions, 3 deletions
diff --git a/ripple/fossil/Cargo.toml b/ripple/fossil/Cargo.toml
index 4008691..a1f39fb 100644
--- a/ripple/fossil/Cargo.toml
+++ b/ripple/fossil/Cargo.toml
@@ -19,6 +19,7 @@ env_logger = "0.9.0"
 lazy_static = "1.4.0"
 bao = "0.12.0"
 anyhow = "1.0.53"
+clap = { version = "3.1.15", features = ["derive"] }
 
 [build-dependencies]
 prost-build = "0.8.0"
diff --git a/ripple/fossil/src/bin/add.rs b/ripple/fossil/src/bin/add.rs
index 114f893..7768366 100644
--- a/ripple/fossil/src/bin/add.rs
+++ b/ripple/fossil/src/bin/add.rs
@@ -2,20 +2,28 @@
 // SPDX-License-Identifier: OSL-3.0
 
 use {
+	clap::StructOpt,
 	fossil::Directory,
 	prost::Message,
 	std::{
-		env,
 		io::{self, Write},
-		path::Path,
+		path::{Path, PathBuf},
 	},
 };
 
+#[derive(clap::Parser)]
+struct Args {
+	#[clap(name = "PATH")]
+	paths: Vec<PathBuf>,
+}
+
 fn main() {
+	let args = Args::parse();
+
 	let store = fossil::Store::open("fossil.db").unwrap();
 	let mut root = Directory::new();
 
-	for name in env::args().skip(1) {
+	for name in args.paths {
 		let path = Path::new(&name);
 		let name = path
 			.file_name()
diff --git a/ripple/fossil/src/bin/extract.rs b/ripple/fossil/src/bin/extract.rs
index b21a063..cb45896 100644
--- a/ripple/fossil/src/bin/extract.rs
+++ b/ripple/fossil/src/bin/extract.rs
@@ -2,6 +2,7 @@
 // SPDX-License-Identifier: OSL-3.0
 
 use {
+	clap::StructOpt,
 	fossil::{store, Directory},
 	prost::Message,
 	std::{
@@ -12,7 +13,12 @@ use {
 	},
 };
 
+#[derive(clap::Parser)]
+struct Args {}
+
 fn main() {
+	let _args = Args::parse();
+
 	let store = fossil::Store::open("fossil.db").unwrap();
 	let root = {
 		let mut stdin = io::stdin();
diff --git a/ripple/fossil/src/bin/mount.rs b/ripple/fossil/src/bin/mount.rs
index 2e6945b..ae26fbb 100644
--- a/ripple/fossil/src/bin/mount.rs
+++ b/ripple/fossil/src/bin/mount.rs
@@ -2,6 +2,7 @@
 // SPDX-License-Identifier: OSL-3.0
 
 use {
+	clap::StructOpt,
 	fossil::{store, FileRef},
 	lazy_static::lazy_static,
 	libc::{c_int, EINVAL, ENOENT, ENOSYS, EROFS},
@@ -71,8 +72,12 @@ fn file_attr(ino: u64, node: &memtree::Node) -> fuser::FileAttr {
 	}
 }
 
+#[derive(clap::Parser)]
+struct Args {}
+
 fn main() {
 	env_logger::init();
+	let _args = Args::parse();
 
 	let store = fossil::Store::open("fossil.db").unwrap();
 	let root = memtree::load_root(&store, {