From 3e98fe46a24d8231ed5f962f5b874032e4994f08 Mon Sep 17 00:00:00 2001 From: m-holger Date: Mon, 7 Feb 2022 13:07:09 +0000 Subject: Tidy example CLI usage Change "-" to "--" for named parameters. Remove spaces inside "[ option ]" for optional parameters. Fix "pdf-mod-info --dump file" to match usage message. --- examples/pdf-bookmarks.cc | 16 ++++++------- examples/pdf-custom-filter.cc | 2 +- examples/pdf-mod-info.cc | 15 ++++++------ examples/qtest/bookmarks.test | 6 ++--- .../qtest/bookmarks/test.--show-open.--lines.out | 22 +++++++++++++++++ .../qtest/bookmarks/test.--show-open.--numbers.out | 11 +++++++++ examples/qtest/bookmarks/test.--show-open.x.out | 11 +++++++++ .../qtest/bookmarks/test.-show-open.-lines.out | 22 ----------------- .../qtest/bookmarks/test.-show-open.-numbers.out | 11 --------- examples/qtest/bookmarks/test.-show-open.x.out | 11 --------- examples/qtest/bookmarks/test.x.--lines.out | 22 +++++++++++++++++ examples/qtest/bookmarks/test.x.--numbers.out | 11 +++++++++ examples/qtest/bookmarks/test.x.-lines.out | 22 ----------------- examples/qtest/bookmarks/test.x.-numbers.out | 11 --------- examples/qtest/mod-info.test | 28 +++++++++++----------- examples/qtest/mod-info/usage.out | 2 +- 16 files changed, 111 insertions(+), 112 deletions(-) create mode 100644 examples/qtest/bookmarks/test.--show-open.--lines.out create mode 100644 examples/qtest/bookmarks/test.--show-open.--numbers.out create mode 100644 examples/qtest/bookmarks/test.--show-open.x.out delete mode 100644 examples/qtest/bookmarks/test.-show-open.-lines.out delete mode 100644 examples/qtest/bookmarks/test.-show-open.-numbers.out delete mode 100644 examples/qtest/bookmarks/test.-show-open.x.out create mode 100644 examples/qtest/bookmarks/test.x.--lines.out create mode 100644 examples/qtest/bookmarks/test.x.--numbers.out delete mode 100644 examples/qtest/bookmarks/test.x.-lines.out delete mode 100644 examples/qtest/bookmarks/test.x.-numbers.out (limited to 'examples') diff --git a/examples/pdf-bookmarks.cc b/examples/pdf-bookmarks.cc index 20a93078..d4501728 100644 --- a/examples/pdf-bookmarks.cc +++ b/examples/pdf-bookmarks.cc @@ -22,13 +22,13 @@ void usage() std::cerr << "Usage: " << whoami << " [options] file.pdf [password]" << std::endl << "Options:" << std::endl - << " -numbers give bookmarks outline-style numbers" + << " --numbers give bookmarks outline-style numbers" << std::endl - << " -lines draw lines to show bookmark hierarchy" + << " --lines draw lines to show bookmark hierarchy" << std::endl - << " -show-open indicate whether a bookmark is initially open" + << " --show-open indicate whether a bookmark is initially open" << std::endl - << " -show-targets show target if possible" + << " --show-targets show target if possible" << std::endl; exit(2); } @@ -177,19 +177,19 @@ int main(int argc, char* argv[]) { if (argv[arg][0] == '-') { - if (strcmp(argv[arg], "-numbers") == 0) + if (strcmp(argv[arg], "--numbers") == 0) { style = st_numbers; } - else if (strcmp(argv[arg], "-lines") == 0) + else if (strcmp(argv[arg], "--lines") == 0) { style = st_lines; } - else if (strcmp(argv[arg], "-show-open") == 0) + else if (strcmp(argv[arg], "--show-open") == 0) { show_open = true; } - else if (strcmp(argv[arg], "-show-targets") == 0) + else if (strcmp(argv[arg], "--show-targets") == 0) { show_targets = true; } diff --git a/examples/pdf-custom-filter.cc b/examples/pdf-custom-filter.cc index ea08de3a..a958a782 100644 --- a/examples/pdf-custom-filter.cc +++ b/examples/pdf-custom-filter.cc @@ -461,7 +461,7 @@ static void usage() { std::cerr << "\n" - << "Usage: " << whoami << " [ --decode-specialized ] infile outfile\n" + << "Usage: " << whoami << " [--decode-specialized] infile outfile\n" << std::endl; exit(2); } diff --git a/examples/pdf-mod-info.cc b/examples/pdf-mod-info.cc index 55b0c8c4..20f13a7a 100644 --- a/examples/pdf-mod-info.cc +++ b/examples/pdf-mod-info.cc @@ -17,7 +17,7 @@ void usage() { std::cerr << "Usage: " << whoami - << " -in in_file [-out out_file] [-key key [-val val]?]+\n" + << " --in in_file [--out out_file] [--key key [--val val]?]+\n" << "Modifies/Adds/Removes PDF /Info entries in the in_file\n" << "and stores the result in out_file\n" << "Special mode: " << whoami << " --dump file\n" @@ -86,11 +86,10 @@ int main(int argc, char* argv[]) std::cout << whoami << " version " << version << std::endl; exit(0); } - if ((argc == 4) && (! strcmp(argv[1], "--dump")) && - (strcmp(argv[2], "-in") == 0) ) + if ((argc == 3) && (! strcmp(argv[1], "--dump"))) { QTC::TC("examples", "pdf-mod-info --dump"); - pdfDumpInfoDict(argv[3]); + pdfDumpInfoDict(argv[2]); exit(0); } @@ -100,11 +99,11 @@ int main(int argc, char* argv[]) for (int i = 1; i < argc; ++i) { - if ((! strcmp(argv[i], "-in")) && (++i < argc)) + if ((! strcmp(argv[i], "--in")) && (++i < argc)) { fl_in = argv[i]; } - else if ((! strcmp(argv[i], "-out")) && (++i < argc)) + else if ((! strcmp(argv[i], "--out")) && (++i < argc)) { fl_out = argv[i]; } @@ -112,7 +111,7 @@ int main(int argc, char* argv[]) { static_id = true; // this should be used in test suites only } - else if ((! strcmp(argv[i], "-key")) && (++i < argc)) + else if ((! strcmp(argv[i], "--key")) && (++i < argc)) { QTC::TC("examples", "pdf-mod-info -key"); cur_key = argv[i]; @@ -122,7 +121,7 @@ int main(int argc, char* argv[]) } Keys[cur_key] = ""; } - else if ((! strcmp(argv[i], "-val")) && (++i < argc)) + else if ((! strcmp(argv[i], "--val")) && (++i < argc)) { if (cur_key.empty()) { diff --git a/examples/qtest/bookmarks.test b/examples/qtest/bookmarks.test index 395357e3..cff8fc60 100644 --- a/examples/qtest/bookmarks.test +++ b/examples/qtest/bookmarks.test @@ -9,9 +9,9 @@ require TestDriver; my $td = new TestDriver('pdf-bookmarks'); -foreach my $show ("", " -show-open") +foreach my $show ("", " --show-open") { - foreach my $style ("", " -lines", " -numbers") + foreach my $style ("", " --lines", " --numbers") { my $xshow = $show ? $show : "x"; my $xstyle = $style ? $style : "x"; @@ -37,7 +37,7 @@ $td->runtest("bad", $td->NORMALIZE_NEWLINES); $td->runtest("encrypted, targets", - {$td->COMMAND => "pdf-bookmarks -show-targets 4.pdf user"}, + {$td->COMMAND => "pdf-bookmarks --show-targets 4.pdf user"}, {$td->FILE => "encrypted.out", $td->EXIT_STATUS => 0}, $td->NORMALIZE_NEWLINES); diff --git a/examples/qtest/bookmarks/test.--show-open.--lines.out b/examples/qtest/bookmarks/test.--show-open.--lines.out new file mode 100644 index 00000000..ea66669c --- /dev/null +++ b/examples/qtest/bookmarks/test.--show-open.--lines.out @@ -0,0 +1,22 @@ +| ++-+ ( ) Trepak 2 -> 15: /XYZ 66 756 3 +| ++-+ (v) Isis 1 -> 5: /XYZ null null null + | + +-+ (>) Amanda 1.1 -> 11: /Fit + | | + | +-+ (>) Isosicle 1.1.1 -> 12: /FitV 100 + | | | + | | +-+ ( ) Isosicle 1.1.1.1 -> 18: /XYZ null null null + | | | + | | +-+ ( ) Isosicle 1.1.1.2 -> 19: /XYZ null null null + | | + | +-+ (v) Isosicle 1.1.2 -> 12: /XYZ null null null + | | + | +-+ ( ) Isosicle 1.1.2.1 -> 22: /XYZ null null null + | + +-+ (v) Sandy 1.2 -> 13: /FitH 792 + | + +-+ ( ) Trepsichord 1.2.1 -> 1: /FitR 66 714 180 770 + | + +-+ ( ) Trepsicle 1.2.2 -> 0: /XYZ null null null diff --git a/examples/qtest/bookmarks/test.--show-open.--numbers.out b/examples/qtest/bookmarks/test.--show-open.--numbers.out new file mode 100644 index 00000000..3680c2d4 --- /dev/null +++ b/examples/qtest/bookmarks/test.--show-open.--numbers.out @@ -0,0 +1,11 @@ +1. ( ) Trepak 2 -> 15: /XYZ 66 756 3 +2. (v) Isis 1 -> 5: /XYZ null null null +2.1. (>) Amanda 1.1 -> 11: /Fit +2.1.1. (>) Isosicle 1.1.1 -> 12: /FitV 100 +2.1.1.1. ( ) Isosicle 1.1.1.1 -> 18: /XYZ null null null +2.1.1.2. ( ) Isosicle 1.1.1.2 -> 19: /XYZ null null null +2.1.2. (v) Isosicle 1.1.2 -> 12: /XYZ null null null +2.1.2.1. ( ) Isosicle 1.1.2.1 -> 22: /XYZ null null null +2.2. (v) Sandy 1.2 -> 13: /FitH 792 +2.2.1. ( ) Trepsichord 1.2.1 -> 1: /FitR 66 714 180 770 +2.2.2. ( ) Trepsicle 1.2.2 -> 0: /XYZ null null null diff --git a/examples/qtest/bookmarks/test.--show-open.x.out b/examples/qtest/bookmarks/test.--show-open.x.out new file mode 100644 index 00000000..46667ef7 --- /dev/null +++ b/examples/qtest/bookmarks/test.--show-open.x.out @@ -0,0 +1,11 @@ +( ) Trepak 2 -> 15: /XYZ 66 756 3 +(v) Isis 1 -> 5: /XYZ null null null +(>) Amanda 1.1 -> 11: /Fit +(>) Isosicle 1.1.1 -> 12: /FitV 100 +( ) Isosicle 1.1.1.1 -> 18: /XYZ null null null +( ) Isosicle 1.1.1.2 -> 19: /XYZ null null null +(v) Isosicle 1.1.2 -> 12: /XYZ null null null +( ) Isosicle 1.1.2.1 -> 22: /XYZ null null null +(v) Sandy 1.2 -> 13: /FitH 792 +( ) Trepsichord 1.2.1 -> 1: /FitR 66 714 180 770 +( ) Trepsicle 1.2.2 -> 0: /XYZ null null null diff --git a/examples/qtest/bookmarks/test.-show-open.-lines.out b/examples/qtest/bookmarks/test.-show-open.-lines.out deleted file mode 100644 index ea66669c..00000000 --- a/examples/qtest/bookmarks/test.-show-open.-lines.out +++ /dev/null @@ -1,22 +0,0 @@ -| -+-+ ( ) Trepak 2 -> 15: /XYZ 66 756 3 -| -+-+ (v) Isis 1 -> 5: /XYZ null null null - | - +-+ (>) Amanda 1.1 -> 11: /Fit - | | - | +-+ (>) Isosicle 1.1.1 -> 12: /FitV 100 - | | | - | | +-+ ( ) Isosicle 1.1.1.1 -> 18: /XYZ null null null - | | | - | | +-+ ( ) Isosicle 1.1.1.2 -> 19: /XYZ null null null - | | - | +-+ (v) Isosicle 1.1.2 -> 12: /XYZ null null null - | | - | +-+ ( ) Isosicle 1.1.2.1 -> 22: /XYZ null null null - | - +-+ (v) Sandy 1.2 -> 13: /FitH 792 - | - +-+ ( ) Trepsichord 1.2.1 -> 1: /FitR 66 714 180 770 - | - +-+ ( ) Trepsicle 1.2.2 -> 0: /XYZ null null null diff --git a/examples/qtest/bookmarks/test.-show-open.-numbers.out b/examples/qtest/bookmarks/test.-show-open.-numbers.out deleted file mode 100644 index 3680c2d4..00000000 --- a/examples/qtest/bookmarks/test.-show-open.-numbers.out +++ /dev/null @@ -1,11 +0,0 @@ -1. ( ) Trepak 2 -> 15: /XYZ 66 756 3 -2. (v) Isis 1 -> 5: /XYZ null null null -2.1. (>) Amanda 1.1 -> 11: /Fit -2.1.1. (>) Isosicle 1.1.1 -> 12: /FitV 100 -2.1.1.1. ( ) Isosicle 1.1.1.1 -> 18: /XYZ null null null -2.1.1.2. ( ) Isosicle 1.1.1.2 -> 19: /XYZ null null null -2.1.2. (v) Isosicle 1.1.2 -> 12: /XYZ null null null -2.1.2.1. ( ) Isosicle 1.1.2.1 -> 22: /XYZ null null null -2.2. (v) Sandy 1.2 -> 13: /FitH 792 -2.2.1. ( ) Trepsichord 1.2.1 -> 1: /FitR 66 714 180 770 -2.2.2. ( ) Trepsicle 1.2.2 -> 0: /XYZ null null null diff --git a/examples/qtest/bookmarks/test.-show-open.x.out b/examples/qtest/bookmarks/test.-show-open.x.out deleted file mode 100644 index 46667ef7..00000000 --- a/examples/qtest/bookmarks/test.-show-open.x.out +++ /dev/null @@ -1,11 +0,0 @@ -( ) Trepak 2 -> 15: /XYZ 66 756 3 -(v) Isis 1 -> 5: /XYZ null null null -(>) Amanda 1.1 -> 11: /Fit -(>) Isosicle 1.1.1 -> 12: /FitV 100 -( ) Isosicle 1.1.1.1 -> 18: /XYZ null null null -( ) Isosicle 1.1.1.2 -> 19: /XYZ null null null -(v) Isosicle 1.1.2 -> 12: /XYZ null null null -( ) Isosicle 1.1.2.1 -> 22: /XYZ null null null -(v) Sandy 1.2 -> 13: /FitH 792 -( ) Trepsichord 1.2.1 -> 1: /FitR 66 714 180 770 -( ) Trepsicle 1.2.2 -> 0: /XYZ null null null diff --git a/examples/qtest/bookmarks/test.x.--lines.out b/examples/qtest/bookmarks/test.x.--lines.out new file mode 100644 index 00000000..a6de7db5 --- /dev/null +++ b/examples/qtest/bookmarks/test.x.--lines.out @@ -0,0 +1,22 @@ +| ++-+ Trepak 2 -> 15: /XYZ 66 756 3 +| ++-+ Isis 1 -> 5: /XYZ null null null + | + +-+ Amanda 1.1 -> 11: /Fit + | | + | +-+ Isosicle 1.1.1 -> 12: /FitV 100 + | | | + | | +-+ Isosicle 1.1.1.1 -> 18: /XYZ null null null + | | | + | | +-+ Isosicle 1.1.1.2 -> 19: /XYZ null null null + | | + | +-+ Isosicle 1.1.2 -> 12: /XYZ null null null + | | + | +-+ Isosicle 1.1.2.1 -> 22: /XYZ null null null + | + +-+ Sandy 1.2 -> 13: /FitH 792 + | + +-+ Trepsichord 1.2.1 -> 1: /FitR 66 714 180 770 + | + +-+ Trepsicle 1.2.2 -> 0: /XYZ null null null diff --git a/examples/qtest/bookmarks/test.x.--numbers.out b/examples/qtest/bookmarks/test.x.--numbers.out new file mode 100644 index 00000000..7ff9e2aa --- /dev/null +++ b/examples/qtest/bookmarks/test.x.--numbers.out @@ -0,0 +1,11 @@ +1. Trepak 2 -> 15: /XYZ 66 756 3 +2. Isis 1 -> 5: /XYZ null null null +2.1. Amanda 1.1 -> 11: /Fit +2.1.1. Isosicle 1.1.1 -> 12: /FitV 100 +2.1.1.1. Isosicle 1.1.1.1 -> 18: /XYZ null null null +2.1.1.2. Isosicle 1.1.1.2 -> 19: /XYZ null null null +2.1.2. Isosicle 1.1.2 -> 12: /XYZ null null null +2.1.2.1. Isosicle 1.1.2.1 -> 22: /XYZ null null null +2.2. Sandy 1.2 -> 13: /FitH 792 +2.2.1. Trepsichord 1.2.1 -> 1: /FitR 66 714 180 770 +2.2.2. Trepsicle 1.2.2 -> 0: /XYZ null null null diff --git a/examples/qtest/bookmarks/test.x.-lines.out b/examples/qtest/bookmarks/test.x.-lines.out deleted file mode 100644 index a6de7db5..00000000 --- a/examples/qtest/bookmarks/test.x.-lines.out +++ /dev/null @@ -1,22 +0,0 @@ -| -+-+ Trepak 2 -> 15: /XYZ 66 756 3 -| -+-+ Isis 1 -> 5: /XYZ null null null - | - +-+ Amanda 1.1 -> 11: /Fit - | | - | +-+ Isosicle 1.1.1 -> 12: /FitV 100 - | | | - | | +-+ Isosicle 1.1.1.1 -> 18: /XYZ null null null - | | | - | | +-+ Isosicle 1.1.1.2 -> 19: /XYZ null null null - | | - | +-+ Isosicle 1.1.2 -> 12: /XYZ null null null - | | - | +-+ Isosicle 1.1.2.1 -> 22: /XYZ null null null - | - +-+ Sandy 1.2 -> 13: /FitH 792 - | - +-+ Trepsichord 1.2.1 -> 1: /FitR 66 714 180 770 - | - +-+ Trepsicle 1.2.2 -> 0: /XYZ null null null diff --git a/examples/qtest/bookmarks/test.x.-numbers.out b/examples/qtest/bookmarks/test.x.-numbers.out deleted file mode 100644 index 7ff9e2aa..00000000 --- a/examples/qtest/bookmarks/test.x.-numbers.out +++ /dev/null @@ -1,11 +0,0 @@ -1. Trepak 2 -> 15: /XYZ 66 756 3 -2. Isis 1 -> 5: /XYZ null null null -2.1. Amanda 1.1 -> 11: /Fit -2.1.1. Isosicle 1.1.1 -> 12: /FitV 100 -2.1.1.1. Isosicle 1.1.1.1 -> 18: /XYZ null null null -2.1.1.2. Isosicle 1.1.1.2 -> 19: /XYZ null null null -2.1.2. Isosicle 1.1.2 -> 12: /XYZ null null null -2.1.2.1. Isosicle 1.1.2.1 -> 22: /XYZ null null null -2.2. Sandy 1.2 -> 13: /FitH 792 -2.2.1. Trepsichord 1.2.1 -> 1: /FitR 66 714 180 770 -2.2.2. Trepsicle 1.2.2 -> 0: /XYZ null null null diff --git a/examples/qtest/mod-info.test b/examples/qtest/mod-info.test index 145bf133..5f927170 100644 --- a/examples/qtest/mod-info.test +++ b/examples/qtest/mod-info.test @@ -16,64 +16,64 @@ my $qpdf = $ENV{'QPDF_BIN'} or die; cleanup(); $td->runtest("usage #1", - {$td->COMMAND => "$prg -in target.pdf"}, + {$td->COMMAND => "$prg --in target.pdf"}, {$td->FILE => "usage.out", $td->EXIT_STATUS => 2}, $td->NORMALIZE_NEWLINES); $td->runtest("usage #2", - {$td->COMMAND => "$prg -key abc -val def"}, + {$td->COMMAND => "$prg --key abc --val def"}, {$td->FILE => "usage.out", $td->EXIT_STATUS => 2}, $td->NORMALIZE_NEWLINES); $td->runtest("usage #3", - {$td->COMMAND => "$prg -key abc -val def abc"}, + {$td->COMMAND => "$prg --key abc --val def abc"}, {$td->FILE => "usage.out", $td->EXIT_STATUS => 2}, $td->NORMALIZE_NEWLINES); $td->runtest("usage #4", - {$td->COMMAND => "$prg -in source1.pdf -key date -val 01/01/01 -val 12/12/12"}, + {$td->COMMAND => "$prg --in source1.pdf --key date --val 01/01/01 --val 12/12/12"}, {$td->FILE => "usage.out", $td->EXIT_STATUS => 2}, $td->NORMALIZE_NEWLINES); $td->runtest("dump #1", - {$td->COMMAND => "$prg --dump -in files/source1.pdf"}, + {$td->COMMAND => "$prg --dump files/source1.pdf"}, {$td->FILE => "dump.out", $td->EXIT_STATUS => 0}, $td->NORMALIZE_NEWLINES); $td->runtest("dump #2", - {$td->COMMAND => "$prg --dump -in files/no-info.pdf"}, + {$td->COMMAND => "$prg --dump files/no-info.pdf"}, {$td->STRING => "", $td->EXIT_STATUS => 0}, $td->NORMALIZE_NEWLINES); $td->runtest("dump #3", - {$td->COMMAND => "$prg --dump -in files/empty-info.pdf"}, + {$td->COMMAND => "$prg --dump files/empty-info.pdf"}, {$td->STRING => "", $td->EXIT_STATUS => 0}); run_and_cmp("modify Subject", - "$prg -in files/source1.pdf -out out.pdf -key Subject " . - "-val \"Export Business\"", + "$prg --in files/source1.pdf --out out.pdf --key Subject " . + "--val \"Export Business\"", "", "out.pdf", "files/1.qdf"); run_and_cmp("add Subject, remove Producer, modify CreationDate", - "$prg -in files/source2.pdf -out out.pdf -key Subject " . - "-val \"Tammlin\" -key Producer -key CreationDate -val 12/12", + "$prg --in files/source2.pdf --out out.pdf --key Subject " . + "--val \"Tammlin\" --key Producer --key CreationDate --val 12/12", "", "out.pdf", "files/2.qdf"); run_and_cmp("add Subject (empty-info file)", - "$prg -in files/empty-info.pdf -out out.pdf -key Subject " . - "-val Tammlin", + "$prg --in files/empty-info.pdf --out out.pdf --key Subject " . + "--val Tammlin", "", "out.pdf", "files/3.qdf"); copy("files/no-info.pdf", "no-info.pdf") or die "can't copy no-info: $!"; run_and_cmp("in-place Producer added (no-info file)", - "$prg -in no-info.pdf -key Producer -val \"Obivan Kinobi\"", + "$prg --in no-info.pdf --key Producer --val \"Obivan Kinobi\"", "", "no-info.pdf", "files/4.qdf"); cleanup(); diff --git a/examples/qtest/mod-info/usage.out b/examples/qtest/mod-info/usage.out index 5eeba82e..13ac3b20 100644 --- a/examples/qtest/mod-info/usage.out +++ b/examples/qtest/mod-info/usage.out @@ -1,4 +1,4 @@ -Usage: pdf-mod-info -in in_file [-out out_file] [-key key [-val val]?]+ +Usage: pdf-mod-info --in in_file [--out out_file] [--key key [--val val]?]+ Modifies/Adds/Removes PDF /Info entries in the in_file and stores the result in out_file Special mode: pdf-mod-info --dump file -- cgit v1.2.3-54-g00ecf