Added more options for input data

+ -b flag allows you to specify the base of the input data, useful if the data does not have a prefix or is a strange base
+ -i allows you to pass in array or string data
This commit is contained in:
joeyahines committed 2022-04-21 19:28:04 -06:00
1 parent d956c111d8
commit 9244cebad3
3 files changed
+124 -55

No files matched your search

+13 -2
View File
@@ -1,6 +1,6 @@
use crate::error::FormatyError;
use crate::formatter::format::Format;
use crate::parser::parse_bytes_from_input_arg;
use crate::parser::InputTypes;
use formatter::FormatConfig;
use std::path::PathBuf;
use structopt::StructOpt;
@@ -21,6 +21,17 @@ pub struct Args {
)]
config: Option<PathBuf>,
#[structopt(
help = "Input data type",
short = "i",
long = "input_type",
default_value = "array"
)]
input_type: InputTypes,
#[structopt(help = "Base of the input values", short = "b", long = "base")]
base: Option<u32>,
#[structopt(help = "Format to parse data as")]
format: String,
@@ -35,7 +46,7 @@ fn init() -> Result<(Vec<u8>, Format), FormatyError> {
let format = config.get_format(&args.format)?;
let data = parse_bytes_from_input_arg(args.data)?;
let data = args.input_type.parse_input(args.data, args.base)?;
Ok((data, format))
}