Add reexport command
This commit is contained in:
parent
266f001d46
commit
e74eee89e6
3 changed files with 25 additions and 0 deletions
5
brood/src/commands.rs
Normal file
5
brood/src/commands.rs
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
mod ingest;
|
||||
mod reexport;
|
||||
|
||||
pub use ingest::ingest;
|
||||
pub use reexport::reexport;
|
||||
17
brood/src/commands/reexport.rs
Normal file
17
brood/src/commands/reexport.rs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
use std::fs::File;
|
||||
use std::io::{self, BufReader, BufWriter};
|
||||
use std::path::Path;
|
||||
|
||||
use crate::data::AdjacencyList;
|
||||
|
||||
pub fn reexport(from: &Path, to: &Path) -> io::Result<()> {
|
||||
eprintln!(">> Import");
|
||||
let from = BufReader::new(File::open(from)?);
|
||||
let data = AdjacencyList::read(from)?;
|
||||
|
||||
eprintln!(">> Export");
|
||||
let to = BufWriter::new(File::create(to)?);
|
||||
data.write(to)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -11,6 +11,8 @@ use clap::Parser;
|
|||
enum Command {
|
||||
/// Read sift data on stdin and output brood data.
|
||||
Ingest,
|
||||
/// Read and reexport brood data.
|
||||
Reexport { to: PathBuf },
|
||||
}
|
||||
|
||||
#[derive(Debug, Parser)]
|
||||
|
|
@ -24,5 +26,6 @@ fn main() -> io::Result<()> {
|
|||
let args = Args::parse();
|
||||
match args.command {
|
||||
Command::Ingest => commands::ingest(&args.datafile),
|
||||
Command::Reexport { to } => commands::reexport(&args.datafile, &to),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue