diff options
author | Teddy Wing | 2023-04-25 21:05:32 +0200 |
---|---|---|
committer | Teddy Wing | 2023-04-25 21:05:32 +0200 |
commit | 090fca140b7833956a52fde85083e9aa7d8c59d2 (patch) | |
tree | 2f253e01b366d2d9e5d679d7ef24bbfda0fd314c | |
parent | 6f19b68c145d6255de800bf7aedd594327647278 (diff) | |
download | pdf-form-replace-font2-090fca140b7833956a52fde85083e9aa7d8c59d2.tar.bz2 |
App.java: Set remaining command line option variables
Set `input`, `find`, `replace`, and `output` from command line
arguments. These will be used to generate the output PDF.
-rw-r--r-- | src/main/java/com/teddywing/pdf_form_replace_font2/App.java | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/main/java/com/teddywing/pdf_form_replace_font2/App.java b/src/main/java/com/teddywing/pdf_form_replace_font2/App.java index 5e45dc0..6f78882 100644 --- a/src/main/java/com/teddywing/pdf_form_replace_font2/App.java +++ b/src/main/java/com/teddywing/pdf_form_replace_font2/App.java @@ -39,13 +39,7 @@ public class App { try { CommandLine options_matches = option_parser.parse(options, args); - String find = options_matches.getOptionValue("find"); - String replace = options_matches.getOptionValue("replace"); - String output = options_matches.getOptionValue("output"); - boolean should_show_help = options_matches.hasOption("help"); - boolean should_show_version = options_matches.hasOption("version"); - if (should_show_help) { HelpFormatter help_formatter = new HelpFormatter(); help_formatter.printHelp("pdf-form-replace-font2", options); @@ -53,6 +47,7 @@ public class App { System.exit(0); } + boolean should_show_version = options_matches.hasOption("version"); if (should_show_version) { Properties properties = new Properties(); InputStream stream = App.class.getResourceAsStream("/META-INF/maven/com.teddywing.pdf_form_replace_font2/pdf-form-replace-font2/pom.properties"); @@ -63,6 +58,31 @@ public class App { System.exit(0); } + + String input = "-"; + String[] free_args = options_matches.getArgs(); + if (free_args.length > 0) { + input = free_args[0]; + } + + String find = options_matches.getOptionValue("find"); + if (find == null) { + System.err.println("error: required option 'find' missing"); + System.exit(64); + } + + String replace = options_matches.getOptionValue("replace"); + if (replace == null) { + System.err.println("error: required option 'replace' missing"); + System.exit(64); + } + + String output = options_matches.getOptionValue("output"); + if (output == null) { + output = "-"; + } + + System.out.println("i:" + input + " f:" + find + " r:" + replace + " o:" + output); } catch (ParseException e) { System.err.println("error: " + e.getMessage()); |