Commit 3e98fe46a24d8231ed5f962f5b874032e4994f08
Committed by
Jay Berkenbilt
1 parent
4fd61981
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.
Showing
11 changed files
with
34 additions
and
35 deletions
examples/pdf-bookmarks.cc
| ... | ... | @@ -22,13 +22,13 @@ void usage() |
| 22 | 22 | std::cerr << "Usage: " << whoami << " [options] file.pdf [password]" |
| 23 | 23 | << std::endl |
| 24 | 24 | << "Options:" << std::endl |
| 25 | - << " -numbers give bookmarks outline-style numbers" | |
| 25 | + << " --numbers give bookmarks outline-style numbers" | |
| 26 | 26 | << std::endl |
| 27 | - << " -lines draw lines to show bookmark hierarchy" | |
| 27 | + << " --lines draw lines to show bookmark hierarchy" | |
| 28 | 28 | << std::endl |
| 29 | - << " -show-open indicate whether a bookmark is initially open" | |
| 29 | + << " --show-open indicate whether a bookmark is initially open" | |
| 30 | 30 | << std::endl |
| 31 | - << " -show-targets show target if possible" | |
| 31 | + << " --show-targets show target if possible" | |
| 32 | 32 | << std::endl; |
| 33 | 33 | exit(2); |
| 34 | 34 | } |
| ... | ... | @@ -177,19 +177,19 @@ int main(int argc, char* argv[]) |
| 177 | 177 | { |
| 178 | 178 | if (argv[arg][0] == '-') |
| 179 | 179 | { |
| 180 | - if (strcmp(argv[arg], "-numbers") == 0) | |
| 180 | + if (strcmp(argv[arg], "--numbers") == 0) | |
| 181 | 181 | { |
| 182 | 182 | style = st_numbers; |
| 183 | 183 | } |
| 184 | - else if (strcmp(argv[arg], "-lines") == 0) | |
| 184 | + else if (strcmp(argv[arg], "--lines") == 0) | |
| 185 | 185 | { |
| 186 | 186 | style = st_lines; |
| 187 | 187 | } |
| 188 | - else if (strcmp(argv[arg], "-show-open") == 0) | |
| 188 | + else if (strcmp(argv[arg], "--show-open") == 0) | |
| 189 | 189 | { |
| 190 | 190 | show_open = true; |
| 191 | 191 | } |
| 192 | - else if (strcmp(argv[arg], "-show-targets") == 0) | |
| 192 | + else if (strcmp(argv[arg], "--show-targets") == 0) | |
| 193 | 193 | { |
| 194 | 194 | show_targets = true; |
| 195 | 195 | } | ... | ... |
examples/pdf-custom-filter.cc
| ... | ... | @@ -461,7 +461,7 @@ static void usage() |
| 461 | 461 | { |
| 462 | 462 | std::cerr |
| 463 | 463 | << "\n" |
| 464 | - << "Usage: " << whoami << " [ --decode-specialized ] infile outfile\n" | |
| 464 | + << "Usage: " << whoami << " [--decode-specialized] infile outfile\n" | |
| 465 | 465 | << std::endl; |
| 466 | 466 | exit(2); |
| 467 | 467 | } | ... | ... |
examples/pdf-mod-info.cc
| ... | ... | @@ -17,7 +17,7 @@ void usage() |
| 17 | 17 | { |
| 18 | 18 | std::cerr |
| 19 | 19 | << "Usage: " << whoami |
| 20 | - << " -in in_file [-out out_file] [-key key [-val val]?]+\n" | |
| 20 | + << " --in in_file [--out out_file] [--key key [--val val]?]+\n" | |
| 21 | 21 | << "Modifies/Adds/Removes PDF /Info entries in the in_file\n" |
| 22 | 22 | << "and stores the result in out_file\n" |
| 23 | 23 | << "Special mode: " << whoami << " --dump file\n" |
| ... | ... | @@ -86,11 +86,10 @@ int main(int argc, char* argv[]) |
| 86 | 86 | std::cout << whoami << " version " << version << std::endl; |
| 87 | 87 | exit(0); |
| 88 | 88 | } |
| 89 | - if ((argc == 4) && (! strcmp(argv[1], "--dump")) && | |
| 90 | - (strcmp(argv[2], "-in") == 0) ) | |
| 89 | + if ((argc == 3) && (! strcmp(argv[1], "--dump"))) | |
| 91 | 90 | { |
| 92 | 91 | QTC::TC("examples", "pdf-mod-info --dump"); |
| 93 | - pdfDumpInfoDict(argv[3]); | |
| 92 | + pdfDumpInfoDict(argv[2]); | |
| 94 | 93 | exit(0); |
| 95 | 94 | } |
| 96 | 95 | |
| ... | ... | @@ -100,11 +99,11 @@ int main(int argc, char* argv[]) |
| 100 | 99 | |
| 101 | 100 | for (int i = 1; i < argc; ++i) |
| 102 | 101 | { |
| 103 | - if ((! strcmp(argv[i], "-in")) && (++i < argc)) | |
| 102 | + if ((! strcmp(argv[i], "--in")) && (++i < argc)) | |
| 104 | 103 | { |
| 105 | 104 | fl_in = argv[i]; |
| 106 | 105 | } |
| 107 | - else if ((! strcmp(argv[i], "-out")) && (++i < argc)) | |
| 106 | + else if ((! strcmp(argv[i], "--out")) && (++i < argc)) | |
| 108 | 107 | { |
| 109 | 108 | fl_out = argv[i]; |
| 110 | 109 | } |
| ... | ... | @@ -112,7 +111,7 @@ int main(int argc, char* argv[]) |
| 112 | 111 | { |
| 113 | 112 | static_id = true; // this should be used in test suites only |
| 114 | 113 | } |
| 115 | - else if ((! strcmp(argv[i], "-key")) && (++i < argc)) | |
| 114 | + else if ((! strcmp(argv[i], "--key")) && (++i < argc)) | |
| 116 | 115 | { |
| 117 | 116 | QTC::TC("examples", "pdf-mod-info -key"); |
| 118 | 117 | cur_key = argv[i]; |
| ... | ... | @@ -122,7 +121,7 @@ int main(int argc, char* argv[]) |
| 122 | 121 | } |
| 123 | 122 | Keys[cur_key] = ""; |
| 124 | 123 | } |
| 125 | - else if ((! strcmp(argv[i], "-val")) && (++i < argc)) | |
| 124 | + else if ((! strcmp(argv[i], "--val")) && (++i < argc)) | |
| 126 | 125 | { |
| 127 | 126 | if (cur_key.empty()) |
| 128 | 127 | { | ... | ... |
examples/qtest/bookmarks.test
| ... | ... | @@ -9,9 +9,9 @@ require TestDriver; |
| 9 | 9 | |
| 10 | 10 | my $td = new TestDriver('pdf-bookmarks'); |
| 11 | 11 | |
| 12 | -foreach my $show ("", " -show-open") | |
| 12 | +foreach my $show ("", " --show-open") | |
| 13 | 13 | { |
| 14 | - foreach my $style ("", " -lines", " -numbers") | |
| 14 | + foreach my $style ("", " --lines", " --numbers") | |
| 15 | 15 | { |
| 16 | 16 | my $xshow = $show ? $show : "x"; |
| 17 | 17 | my $xstyle = $style ? $style : "x"; |
| ... | ... | @@ -37,7 +37,7 @@ $td->runtest("bad", |
| 37 | 37 | $td->NORMALIZE_NEWLINES); |
| 38 | 38 | |
| 39 | 39 | $td->runtest("encrypted, targets", |
| 40 | - {$td->COMMAND => "pdf-bookmarks -show-targets 4.pdf user"}, | |
| 40 | + {$td->COMMAND => "pdf-bookmarks --show-targets 4.pdf user"}, | |
| 41 | 41 | {$td->FILE => "encrypted.out", |
| 42 | 42 | $td->EXIT_STATUS => 0}, |
| 43 | 43 | $td->NORMALIZE_NEWLINES); | ... | ... |
examples/qtest/bookmarks/test.-show-open.-lines.out renamed to examples/qtest/bookmarks/test.--show-open.--lines.out
examples/qtest/bookmarks/test.-show-open.-numbers.out renamed to examples/qtest/bookmarks/test.--show-open.--numbers.out
examples/qtest/bookmarks/test.-show-open.x.out renamed to examples/qtest/bookmarks/test.--show-open.x.out
examples/qtest/bookmarks/test.x.-lines.out renamed to examples/qtest/bookmarks/test.x.--lines.out
examples/qtest/bookmarks/test.x.-numbers.out renamed to examples/qtest/bookmarks/test.x.--numbers.out
examples/qtest/mod-info.test
| ... | ... | @@ -16,64 +16,64 @@ my $qpdf = $ENV{'QPDF_BIN'} or die; |
| 16 | 16 | cleanup(); |
| 17 | 17 | |
| 18 | 18 | $td->runtest("usage #1", |
| 19 | - {$td->COMMAND => "$prg -in target.pdf"}, | |
| 19 | + {$td->COMMAND => "$prg --in target.pdf"}, | |
| 20 | 20 | {$td->FILE => "usage.out", |
| 21 | 21 | $td->EXIT_STATUS => 2}, |
| 22 | 22 | $td->NORMALIZE_NEWLINES); |
| 23 | 23 | |
| 24 | 24 | $td->runtest("usage #2", |
| 25 | - {$td->COMMAND => "$prg -key abc -val def"}, | |
| 25 | + {$td->COMMAND => "$prg --key abc --val def"}, | |
| 26 | 26 | {$td->FILE => "usage.out", |
| 27 | 27 | $td->EXIT_STATUS => 2}, |
| 28 | 28 | $td->NORMALIZE_NEWLINES); |
| 29 | 29 | |
| 30 | 30 | $td->runtest("usage #3", |
| 31 | - {$td->COMMAND => "$prg -key abc -val def abc"}, | |
| 31 | + {$td->COMMAND => "$prg --key abc --val def abc"}, | |
| 32 | 32 | {$td->FILE => "usage.out", |
| 33 | 33 | $td->EXIT_STATUS => 2}, |
| 34 | 34 | $td->NORMALIZE_NEWLINES); |
| 35 | 35 | |
| 36 | 36 | $td->runtest("usage #4", |
| 37 | - {$td->COMMAND => "$prg -in source1.pdf -key date -val 01/01/01 -val 12/12/12"}, | |
| 37 | + {$td->COMMAND => "$prg --in source1.pdf --key date --val 01/01/01 --val 12/12/12"}, | |
| 38 | 38 | {$td->FILE => "usage.out", |
| 39 | 39 | $td->EXIT_STATUS => 2}, |
| 40 | 40 | $td->NORMALIZE_NEWLINES); |
| 41 | 41 | |
| 42 | 42 | $td->runtest("dump #1", |
| 43 | - {$td->COMMAND => "$prg --dump -in files/source1.pdf"}, | |
| 43 | + {$td->COMMAND => "$prg --dump files/source1.pdf"}, | |
| 44 | 44 | {$td->FILE => "dump.out", |
| 45 | 45 | $td->EXIT_STATUS => 0}, |
| 46 | 46 | $td->NORMALIZE_NEWLINES); |
| 47 | 47 | |
| 48 | 48 | $td->runtest("dump #2", |
| 49 | - {$td->COMMAND => "$prg --dump -in files/no-info.pdf"}, | |
| 49 | + {$td->COMMAND => "$prg --dump files/no-info.pdf"}, | |
| 50 | 50 | {$td->STRING => "", |
| 51 | 51 | $td->EXIT_STATUS => 0}, |
| 52 | 52 | $td->NORMALIZE_NEWLINES); |
| 53 | 53 | |
| 54 | 54 | $td->runtest("dump #3", |
| 55 | - {$td->COMMAND => "$prg --dump -in files/empty-info.pdf"}, | |
| 55 | + {$td->COMMAND => "$prg --dump files/empty-info.pdf"}, | |
| 56 | 56 | {$td->STRING => "", |
| 57 | 57 | $td->EXIT_STATUS => 0}); |
| 58 | 58 | |
| 59 | 59 | run_and_cmp("modify Subject", |
| 60 | - "$prg -in files/source1.pdf -out out.pdf -key Subject " . | |
| 61 | - "-val \"Export Business\"", | |
| 60 | + "$prg --in files/source1.pdf --out out.pdf --key Subject " . | |
| 61 | + "--val \"Export Business\"", | |
| 62 | 62 | "", "out.pdf", "files/1.qdf"); |
| 63 | 63 | |
| 64 | 64 | run_and_cmp("add Subject, remove Producer, modify CreationDate", |
| 65 | - "$prg -in files/source2.pdf -out out.pdf -key Subject " . | |
| 66 | - "-val \"Tammlin\" -key Producer -key CreationDate -val 12/12", | |
| 65 | + "$prg --in files/source2.pdf --out out.pdf --key Subject " . | |
| 66 | + "--val \"Tammlin\" --key Producer --key CreationDate --val 12/12", | |
| 67 | 67 | "", "out.pdf", "files/2.qdf"); |
| 68 | 68 | |
| 69 | 69 | run_and_cmp("add Subject (empty-info file)", |
| 70 | - "$prg -in files/empty-info.pdf -out out.pdf -key Subject " . | |
| 71 | - "-val Tammlin", | |
| 70 | + "$prg --in files/empty-info.pdf --out out.pdf --key Subject " . | |
| 71 | + "--val Tammlin", | |
| 72 | 72 | "", "out.pdf", "files/3.qdf"); |
| 73 | 73 | |
| 74 | 74 | copy("files/no-info.pdf", "no-info.pdf") or die "can't copy no-info: $!"; |
| 75 | 75 | run_and_cmp("in-place Producer added (no-info file)", |
| 76 | - "$prg -in no-info.pdf -key Producer -val \"Obivan Kinobi\"", | |
| 76 | + "$prg --in no-info.pdf --key Producer --val \"Obivan Kinobi\"", | |
| 77 | 77 | "", "no-info.pdf", "files/4.qdf"); |
| 78 | 78 | |
| 79 | 79 | cleanup(); | ... | ... |
examples/qtest/mod-info/usage.out
| 1 | -Usage: pdf-mod-info -in in_file [-out out_file] [-key key [-val val]?]+ | |
| 1 | +Usage: pdf-mod-info --in in_file [--out out_file] [--key key [--val val]?]+ | |
| 2 | 2 | Modifies/Adds/Removes PDF /Info entries in the in_file |
| 3 | 3 | and stores the result in out_file |
| 4 | 4 | Special mode: pdf-mod-info --dump file | ... | ... |