Initial Commit
+ Basic implementation working with just unsigned ints + Can fetch data from arbitrary bit positions in a byte string + TOML config implementation for describing data + Simple CLI
This commit is contained in:
8 files changed
+591
No files matched your search
+37
@@ -0,0 +1,37 @@
|
||||
use crate::parser::parse_bytes_from_input_arg;
|
||||
use formatter::FormatConfig;
|
||||
use std::path::PathBuf;
|
||||
use structopt::StructOpt;
|
||||
|
||||
mod byte_stream;
|
||||
mod formatter;
|
||||
mod parser;
|
||||
|
||||
#[derive(Debug, StructOpt)]
|
||||
#[structopt(name = "Formaty", about = "Arbitrary Binary Data Formatting")]
|
||||
pub struct Args {
|
||||
#[structopt(parse(from_os_str))]
|
||||
config: PathBuf,
|
||||
|
||||
format: String,
|
||||
|
||||
data: Vec<String>,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args: Args = Args::from_args();
|
||||
|
||||
let config = FormatConfig::new(&args.config).unwrap();
|
||||
|
||||
let format = match config.formats.iter().find(|f| f.name == args.format) {
|
||||
None => {
|
||||
println!("Format not found in config file");
|
||||
return;
|
||||
}
|
||||
Some(format) => format,
|
||||
};
|
||||
|
||||
let data = parse_bytes_from_input_arg(args.data).unwrap();
|
||||
|
||||
println!("{}", format.format_data(&data));
|
||||
}
|
||||
Reference in new issue
Block a user