diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs index 0577197..ff765e1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ use derive_builder::Builder; +use getopts::Options; use pdf_forms::{Form, FieldType}; use serde::{Deserialize, Serialize}; @@ -27,9 +28,20 @@ struct Field<'a> { fn main() { let args: Vec<String> = env::args().collect(); - let mut form = Form::load("./f1040.pdf").unwrap(); + let mut opts = Options::new(); + opts.optflag("", "fill", "fill in the form using a markup file"); - if args.len() == 2 && args[1] == "--fill" { + let opt_matches = opts.parse(&args[1..]).unwrap(); + + if opt_matches.free.is_empty() { + return; + } + + let form_path = &opt_matches.free[0]; + + let mut form = Form::load(form_path).unwrap(); + + if opt_matches.opt_present("fill") { fill("./f1040.toml", &mut form); return; |