Commit d926d7805963901d2c7cd10198f2cb125e363210
1 parent
2c6fe180
Add --verbose flag
Showing
5 changed files
with
35 additions
and
4 deletions
ChangeLog
manual/qpdf-manual.xml
| ... | ... | @@ -285,6 +285,15 @@ make |
| 285 | 285 | </listitem> |
| 286 | 286 | </varlistentry> |
| 287 | 287 | <varlistentry> |
| 288 | + <term><option>--verbose</option></term> | |
| 289 | + <listitem> | |
| 290 | + <para> | |
| 291 | + Increase verbosity of output. For now, this just prints some | |
| 292 | + indication of any file that it creates. | |
| 293 | + </para> | |
| 294 | + </listitem> | |
| 295 | + </varlistentry> | |
| 296 | + <varlistentry> | |
| 288 | 297 | <term><option>--linearize</option></term> |
| 289 | 298 | <listitem> |
| 290 | 299 | <para> | ... | ... |
qpdf/qpdf.cc
| ... | ... | @@ -44,6 +44,7 @@ struct Options |
| 44 | 44 | linearize(false), |
| 45 | 45 | decrypt(false), |
| 46 | 46 | split_pages(0), |
| 47 | + verbose(false), | |
| 47 | 48 | copy_encryption(false), |
| 48 | 49 | encryption_file(0), |
| 49 | 50 | encryption_file_password(0), |
| ... | ... | @@ -99,6 +100,7 @@ struct Options |
| 99 | 100 | bool linearize; |
| 100 | 101 | bool decrypt; |
| 101 | 102 | int split_pages; |
| 103 | + bool verbose; | |
| 102 | 104 | bool copy_encryption; |
| 103 | 105 | char const* encryption_file; |
| 104 | 106 | char const* encryption_file_password; |
| ... | ... | @@ -198,6 +200,7 @@ Basic Options\n\ |
| 198 | 200 | -------------\n\ |
| 199 | 201 | \n\ |
| 200 | 202 | --password=password specify a password for accessing encrypted files\n\ |
| 203 | +--verbose provide additional informational output\n\ | |
| 201 | 204 | --linearize generated a linearized (web optimized) file\n\ |
| 202 | 205 | --copy-encryption=file copy encryption parameters from specified file\n\ |
| 203 | 206 | --encryption-file-password=password\n\ |
| ... | ... | @@ -1341,6 +1344,10 @@ static void parse_options(int argc, char* argv[], Options& o) |
| 1341 | 1344 | int n = ((parameter == 0) ? 1 : atoi(parameter)); |
| 1342 | 1345 | o.split_pages = n; |
| 1343 | 1346 | } |
| 1347 | + else if (strcmp(arg, "verbose") == 0) | |
| 1348 | + { | |
| 1349 | + o.verbose = true; | |
| 1350 | + } | |
| 1344 | 1351 | else if (strcmp(arg, "deterministic-id") == 0) |
| 1345 | 1352 | { |
| 1346 | 1353 | o.deterministic_id = true; |
| ... | ... | @@ -2033,6 +2040,10 @@ static void write_outfile(QPDF& pdf, Options& o) |
| 2033 | 2040 | QPDFWriter w(outpdf, outfile.c_str()); |
| 2034 | 2041 | set_writer_options(outpdf, o, w); |
| 2035 | 2042 | w.write(); |
| 2043 | + if (o.verbose) | |
| 2044 | + { | |
| 2045 | + std::cout << whoami << ": wrote file " << outfile << std::endl; | |
| 2046 | + } | |
| 2036 | 2047 | } |
| 2037 | 2048 | } |
| 2038 | 2049 | else |
| ... | ... | @@ -2044,6 +2055,11 @@ static void write_outfile(QPDF& pdf, Options& o) |
| 2044 | 2055 | QPDFWriter w(pdf, o.outfilename); |
| 2045 | 2056 | set_writer_options(pdf, o, w); |
| 2046 | 2057 | w.write(); |
| 2058 | + if (o.verbose && o.outfilename) | |
| 2059 | + { | |
| 2060 | + std::cout << whoami << ": wrote file " | |
| 2061 | + << o.outfilename << std::endl; | |
| 2062 | + } | |
| 2047 | 2063 | } |
| 2048 | 2064 | } |
| 2049 | 2065 | ... | ... |
qpdf/qtest/qpdf.test
| ... | ... | @@ -325,8 +325,8 @@ $td->runtest("check obj0.pdf", |
| 325 | 325 | |
| 326 | 326 | # Min/Force version |
| 327 | 327 | $td->runtest("set min version", |
| 328 | - {$td->COMMAND => "qpdf --min-version=1.6 good1.pdf a.pdf"}, | |
| 329 | - {$td->STRING => "", | |
| 328 | + {$td->COMMAND => "qpdf --verbose --min-version=1.6 good1.pdf a.pdf"}, | |
| 329 | + {$td->STRING => "qpdf: wrote file a.pdf\n", | |
| 330 | 330 | $td->EXIT_STATUS => 0}, |
| 331 | 331 | $td->NORMALIZE_NEWLINES); |
| 332 | 332 | $td->runtest("check version", |
| ... | ... | @@ -730,8 +730,8 @@ for (@sp_cases) |
| 730 | 730 | |
| 731 | 731 | $td->runtest("split page group > 1", |
| 732 | 732 | {$td->COMMAND => "qpdf --static-id --split-pages=5 11-pages.pdf" . |
| 733 | - " split-out-group.pdf"}, | |
| 734 | - {$td->STRING => "", $td->EXIT_STATUS => 0}, | |
| 733 | + " --verbose split-out-group.pdf"}, | |
| 734 | + {$td->FILE => "split-pages-group.out", $td->EXIT_STATUS => 0}, | |
| 735 | 735 | $td->NORMALIZE_NEWLINES); |
| 736 | 736 | foreach my $f ('01-05', '06-10', '11-11') |
| 737 | 737 | { | ... | ... |
qpdf/qtest/qpdf/split-pages-group.out
0 → 100644