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:
3 files changed
+124
-55
No files matched your search
+13
-2
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user