diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/main.rs | 21 |
1 files changed, 6 insertions, 15 deletions
diff --git a/src/main.rs b/src/main.rs index 03bcff3..37644c0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,38 +1,29 @@ pub mod qif; +use clap::Parser; use qif::*; 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); - if path.is_file() { - Ok(path) - } else { - Err(str.to_os_string()) - } -} - -#[derive(StructOpt, Debug)] +/// Qif file preprocessor to decrease duplication when importing to gnucash +#[derive(Parser, Debug)] #[structopt( name = "Qif Parser", - about = "Qif file preprocessor to decrease duplication when importing to gnucash" + version, about, long_about = None )] struct CliArgs { /// Files to preprocess - #[structopt(parse(try_from_os_str = parse_filepath))] + #[arg(value_hint = clap::ValueHint::FilePath)] files: Vec<PathBuf>, } fn main() -> Result<(), Box<dyn Error>> { - let args = CliArgs::from_args(); + let args = CliArgs::parse(); for filepath in &args.files { let file = File::open(filepath)?; |