From 6b25d87d570d5b0950231a7809bf1913af9c5a9d Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Tue, 4 May 2021 00:47:51 +0200 Subject: Begin defining command line options --- src/main.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index ddbf2f7..e9e198d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,30 @@ +use getopts::Options; use lopdf::{Document, Object}; +use std::env; + fn main() { + let args: Vec = env::args().collect(); + + let mut opts = Options::new(); + opts.reqopt("f", "find", "original font", ""); + opts.reqopt("r", "replace", "replacement font", ""); + opts.optopt("o", "output", "output file", "FILE"); + + opts.optflag("h", "help", "print this help menu"); + opts.optflag("V", "version", "show the program version"); + + let opt_matches = opts.parse(&args[1..])?; + + let input_pdf = if opt_matches.free.is_empty() { + "-" + } else { + opt_matches.free[0] + }; + + let output_pdf = opt_matches.opt_str("output").unwrap_or("-"); + let mut doc = Document::load("./f1040.pdf").unwrap(); for (_, mut obj) in &mut doc.objects { -- cgit v1.2.3