aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeddy Wing2021-05-04 00:47:51 +0200
committerTeddy Wing2021-05-04 00:47:51 +0200
commit6b25d87d570d5b0950231a7809bf1913af9c5a9d (patch)
treee85ef9b8351461333151636fe08a9bf4b04ba23e
parente33a1a0fb943442c24ebb702502c46b77eedb9bb (diff)
downloadpdf-form-replace-font-6b25d87d570d5b0950231a7809bf1913af9c5a9d.tar.bz2
Begin defining command line options
-rw-r--r--Cargo.toml1
-rw-r--r--src/main.rs23
2 files changed, 24 insertions, 0 deletions
diff --git a/Cargo.toml b/Cargo.toml
index 01e6693..4f190e2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -4,4 +4,5 @@ version = "0.0.1"
edition = "2018"
[dependencies]
+getopts = "0.2.21"
lopdf = "0.26.0"
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<String> = 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 {