From fef39650efa65b4033b262e440d0f85999602412 Mon Sep 17 00:00:00 2001 From: Justin Wernick Date: Wed, 3 Mar 2021 20:20:13 +0200 Subject: Update to modern Rust --- src/main.rs | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'src/main.rs') 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 { let path: PathBuf = ::std::convert::From::from(str); @@ -28,15 +21,19 @@ fn parse_filepath(str: &OsStr) -> Result { } #[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 + /// Files to preprocess + #[structopt(parse(try_from_os_str = parse_filepath))] + files: Vec, } -fn main() -> Result<(), Box> { +fn main() -> Result<(), Box> { let args = CliArgs::from_args(); - + for filepath in &args.files { let file = File::open(filepath)?; let file_reader = BufReader::new(file); -- cgit v1.2.3