diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/src/main.rs b/src/main.rs index 8874ea9..03bcff3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,22 +1,15 @@ -extern crate regex; -#[macro_use] extern crate lazy_static; -extern crate structopt; -#[macro_use] extern crate structopt_derive; - pub mod qif; -use structopt::StructOpt; - use qif::*; -use std::io::prelude::*; -use std::io::*; - -use std::ffi::{OsString, OsStr}; -use std::path::PathBuf; -use std::result::Result; - -use std::fs::File; -use std::error::Error; +use std::{ + error::Error, + ffi::{OsStr, OsString}, + fs::File, + io::{prelude::*, *}, + path::PathBuf, + result::Result, +}; +use structopt::StructOpt; fn parse_filepath(str: &OsStr) -> Result<PathBuf, OsString> { let path: PathBuf = ::std::convert::From::from(str); @@ -28,15 +21,19 @@ fn parse_filepath(str: &OsStr) -> Result<PathBuf, OsString> { } #[derive(StructOpt, Debug)] -#[structopt(name = "Qif Parser", about = "Qif file preprocessor to decrease duplication when importing to gnucash")] +#[structopt( + name = "Qif Parser", + about = "Qif file preprocessor to decrease duplication when importing to gnucash" +)] struct CliArgs { - #[structopt(help = "Files to preprocess", required, parse(try_from_os_str="parse_filepath"))] - files: Vec<PathBuf> + /// Files to preprocess + #[structopt(parse(try_from_os_str = parse_filepath))] + files: Vec<PathBuf>, } -fn main() -> Result<(), Box<Error>> { +fn main() -> Result<(), Box<dyn Error>> { let args = CliArgs::from_args(); - + for filepath in &args.files { let file = File::open(filepath)?; let file_reader = BufReader::new(file); |