Added support for layered formats
+ Formats can include sub-formats of previously defined formats + This search is done post config building so any format in the global config can be used + Clippy + fmt
This commit is contained in:
5 files changed
+147
-35
No files matched your search
+5
-5
@@ -55,7 +55,7 @@ pub struct Args {
|
||||
data: Vec<String>,
|
||||
}
|
||||
|
||||
fn init() -> Result<(Vec<u8>, Format), FormatyError> {
|
||||
fn init() -> Result<(Vec<u8>, Format, FormatConfig), FormatyError> {
|
||||
let args: Args = Args::from_args();
|
||||
|
||||
let config = FormatConfig::new(&args.config, &args.global_config)?;
|
||||
@@ -70,19 +70,19 @@ fn init() -> Result<(Vec<u8>, Format), FormatyError> {
|
||||
args.input_type.parse_arg_input(args.data, args.base)?
|
||||
};
|
||||
|
||||
Ok((data, format))
|
||||
Ok((data, format, config))
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let (data, format) = match init() {
|
||||
Ok((data, format)) => (data, format),
|
||||
let (data, format, config) = match init() {
|
||||
Ok((data, format, config)) => (data, format, config),
|
||||
Err(e) => {
|
||||
println!("Error initializing: {}", e);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
match format.format_data(&data) {
|
||||
match format.format_data(&data, &config) {
|
||||
Ok(data) => println!("{}", data),
|
||||
Err(_) => print!("Unable to parse data"),
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user