summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJustin Wernick <justin@worthe-it.co.za>2023-03-20 14:20:20 +0200
committerJustin Wernick <justin@worthe-it.co.za>2023-03-20 14:33:42 +0200
commit98242044d9e26b87a3d782f430058bd61435df1f (patch)
tree612998d27327e7586de54fc555355997aa2d05b2 /src
parent18300f4e87be58e5c42c34ec81eed38b4bae4d91 (diff)
Update dependencies
Diffstat (limited to 'src')
-rw-r--r--src/main.rs21
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)?;