aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/geniza-sleep.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/bin/geniza-sleep.rs')
-rw-r--r--src/bin/geniza-sleep.rs46
1 files changed, 46 insertions, 0 deletions
diff --git a/src/bin/geniza-sleep.rs b/src/bin/geniza-sleep.rs
index dafa33c..2e504b0 100644
--- a/src/bin/geniza-sleep.rs
+++ b/src/bin/geniza-sleep.rs
@@ -31,6 +31,13 @@ fn run() -> Result<()> {
.arg_from_usage("<prefix> 'prefix for each data file'"),
)
.subcommand(
+ SubCommand::with_name("chunk")
+ .about("Dumps raw data for a single given chunk from a register (by index)")
+ .arg_from_usage("<DIR> 'directory containing files'")
+ .arg_from_usage("<prefix> 'prefix for each data file'")
+ .arg_from_usage("<index> 'index of the data chunk to dump'"),
+ )
+ .subcommand(
SubCommand::with_name("file-info")
.about("Reads a single SLEEP file and shows some basic metadata")
.arg_from_usage("<FILE> 'SLEEP file to read'"),
@@ -48,6 +55,18 @@ fn run() -> Result<()> {
.about("Reads a single SLEEP file, iterates through all entries, prints raw bytes")
.arg_from_usage("<FILE> 'SLEEP file to read'"),
)
+ .subcommand(
+ SubCommand::with_name("file-chunk")
+ .about("Dumps raw data for a single given chunk from a SLEEP file (by index)")
+ .arg_from_usage("<FILE> 'SLEEP file to read'")
+ .arg_from_usage("<index> 'index of the data chunk to dump'"),
+ )
+ .subcommand(
+ SubCommand::with_name("write-example-alphabet")
+ .about("Creates a content register in the given folder, with example data added")
+ .arg_from_usage("<DIR> 'directory containing files'")
+ .arg_from_usage("<prefix> 'prefix for each data file'")
+ )
.get_matches();
@@ -66,6 +85,14 @@ fn run() -> Result<()> {
SleepDirRegister::create(dir, prefix)?;
println!("Done!");
}
+ ("chunk", Some(subm)) => {
+ let dir = Path::new(subm.value_of("DIR").unwrap());
+ let prefix = subm.value_of("prefix").unwrap();
+ let index = value_t_or_exit!(subm, "index", u64);
+ let mut sdr = SleepDirRegister::open(dir, prefix, false)?;
+ //debug!(println!("{:?}", sdr));
+ println!("{:?}", sdr.get_data_entry(index)?);
+ }
("file-info", Some(subm)) => {
let path = Path::new(subm.value_of("FILE").unwrap());
let sf = SleepFile::open(path, false)?;
@@ -101,6 +128,25 @@ fn run() -> Result<()> {
println!("{}: {:?}", i, sf.read(i));
}
}
+ ("file-chunk", Some(subm)) => {
+ let path = Path::new(subm.value_of("FILE").unwrap());
+ let index = value_t_or_exit!(subm, "index", u64);
+ let mut sf = SleepFile::open(path, false)?;
+ //debug!(println!("{:?}", sdr));
+ println!("{:?}", sf.read(index)?);
+ }
+ ("write-example-alphabet", Some(subm)) => {
+ let dir = Path::new(subm.value_of("DIR").unwrap());
+ let prefix = subm.value_of("prefix").unwrap();
+ let mut sdr = SleepDirRegister::create(dir, prefix)?;
+ sdr.append(&[0x61; 1])?; // a
+ sdr.append(&[0x62; 1])?; // b
+ sdr.append(&[0x63; 1])?; // c
+ sdr.append(&[0x64; 1])?; // d
+ sdr.append(&[0x65; 1])?; // e
+ sdr.append(&[0x66; 1])?; // f
+ println!("Done!");
+ }
_ => {
println!("Missing or unimplemented command!");
println!("{}", matches.usage());