an efficient binary archive format
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

cat -> read, add optional output argument

zach 66674193 7397663d

+19 -6
+1 -1
Cargo.toml
··· 1 1 [package] 2 2 name = "bindle-file" 3 - version = "0.0.2" 3 + version = "0.1.0" 4 4 edition = "2024" 5 5 authors = ["Zach Shipko <zachshipko@gmail.com>"] 6 6 license = "ISC"
+1 -1
README.md
··· 68 68 69 69 ```bash 70 70 bindle add archive.bndl file.txt 71 - bindle cat archive.bndl file.txt 71 + bindle read archive.bndl file.txt 72 72 bindle pack archive.bndl /some/dir 73 73 bindle unpack archive.bndl /unpack/to/dir 74 74 bindle list archive.bndl
+17 -4
src/bin/bindle.rs
··· 45 45 vacuum: bool, 46 46 }, 47 47 48 - /// Extract an entry's data to stdout 49 - Cat { 48 + #[command(visible_alias = "cat")] 49 + /// Extract an entry's data 50 + Read { 50 51 /// Bindle archive file 51 52 #[arg(value_name = "BINDLE_FILE")] 52 53 bindle_file: PathBuf, 53 54 /// Name of the entry to extract 54 55 name: String, 56 + /// Output path 57 + #[arg(short, long)] 58 + output: Option<PathBuf>, 55 59 }, 56 60 57 61 /// Remove an entry from the archive ··· 205 209 println!("OK"); 206 210 } 207 211 208 - Commands::Cat { name, bindle_file } => { 212 + Commands::Read { 213 + name, 214 + bindle_file, 215 + output, 216 + } => { 209 217 let b = init_load(bindle_file.clone()); 210 - match b.read_to(name.as_str(), io::stdout()) { 218 + let res = if let Some(output) = output { 219 + b.read_to(name.as_str(), std::fs::File::create(output)?) 220 + } else { 221 + b.read_to(name.as_str(), io::stdout()) 222 + }; 223 + match res { 211 224 Ok(_n) => {} 212 225 Err(e) => { 213 226 return Err(io::Error::new(io::ErrorKind::NotFound, e));