Commit d926d7805963901d2c7cd10198f2cb125e363210
1 parent
2c6fe180
Add --verbose flag
Showing
5 changed files
with
35 additions
and
4 deletions
ChangeLog
| 1 | 2017-08-12 Jay Berkenbilt <ejb@ql.org> | 1 | 2017-08-12 Jay Berkenbilt <ejb@ql.org> |
| 2 | 2 | ||
| 3 | + * Provide --verbose option that causes qpdf to print an indication | ||
| 4 | + of what files it is writing. | ||
| 5 | + | ||
| 3 | * Change --single-pages to --split-pages and make it take an | 6 | * Change --single-pages to --split-pages and make it take an |
| 4 | optional argument specifying the number of pages per file. | 7 | optional argument specifying the number of pages per file. |
| 5 | 8 |
manual/qpdf-manual.xml
| @@ -285,6 +285,15 @@ make | @@ -285,6 +285,15 @@ make | ||
| 285 | </listitem> | 285 | </listitem> |
| 286 | </varlistentry> | 286 | </varlistentry> |
| 287 | <varlistentry> | 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 | <term><option>--linearize</option></term> | 297 | <term><option>--linearize</option></term> |
| 289 | <listitem> | 298 | <listitem> |
| 290 | <para> | 299 | <para> |
qpdf/qpdf.cc
| @@ -44,6 +44,7 @@ struct Options | @@ -44,6 +44,7 @@ struct Options | ||
| 44 | linearize(false), | 44 | linearize(false), |
| 45 | decrypt(false), | 45 | decrypt(false), |
| 46 | split_pages(0), | 46 | split_pages(0), |
| 47 | + verbose(false), | ||
| 47 | copy_encryption(false), | 48 | copy_encryption(false), |
| 48 | encryption_file(0), | 49 | encryption_file(0), |
| 49 | encryption_file_password(0), | 50 | encryption_file_password(0), |
| @@ -99,6 +100,7 @@ struct Options | @@ -99,6 +100,7 @@ struct Options | ||
| 99 | bool linearize; | 100 | bool linearize; |
| 100 | bool decrypt; | 101 | bool decrypt; |
| 101 | int split_pages; | 102 | int split_pages; |
| 103 | + bool verbose; | ||
| 102 | bool copy_encryption; | 104 | bool copy_encryption; |
| 103 | char const* encryption_file; | 105 | char const* encryption_file; |
| 104 | char const* encryption_file_password; | 106 | char const* encryption_file_password; |
| @@ -198,6 +200,7 @@ Basic Options\n\ | @@ -198,6 +200,7 @@ Basic Options\n\ | ||
| 198 | -------------\n\ | 200 | -------------\n\ |
| 199 | \n\ | 201 | \n\ |
| 200 | --password=password specify a password for accessing encrypted files\n\ | 202 | --password=password specify a password for accessing encrypted files\n\ |
| 203 | +--verbose provide additional informational output\n\ | ||
| 201 | --linearize generated a linearized (web optimized) file\n\ | 204 | --linearize generated a linearized (web optimized) file\n\ |
| 202 | --copy-encryption=file copy encryption parameters from specified file\n\ | 205 | --copy-encryption=file copy encryption parameters from specified file\n\ |
| 203 | --encryption-file-password=password\n\ | 206 | --encryption-file-password=password\n\ |
| @@ -1341,6 +1344,10 @@ static void parse_options(int argc, char* argv[], Options& o) | @@ -1341,6 +1344,10 @@ static void parse_options(int argc, char* argv[], Options& o) | ||
| 1341 | int n = ((parameter == 0) ? 1 : atoi(parameter)); | 1344 | int n = ((parameter == 0) ? 1 : atoi(parameter)); |
| 1342 | o.split_pages = n; | 1345 | o.split_pages = n; |
| 1343 | } | 1346 | } |
| 1347 | + else if (strcmp(arg, "verbose") == 0) | ||
| 1348 | + { | ||
| 1349 | + o.verbose = true; | ||
| 1350 | + } | ||
| 1344 | else if (strcmp(arg, "deterministic-id") == 0) | 1351 | else if (strcmp(arg, "deterministic-id") == 0) |
| 1345 | { | 1352 | { |
| 1346 | o.deterministic_id = true; | 1353 | o.deterministic_id = true; |
| @@ -2033,6 +2040,10 @@ static void write_outfile(QPDF& pdf, Options& o) | @@ -2033,6 +2040,10 @@ static void write_outfile(QPDF& pdf, Options& o) | ||
| 2033 | QPDFWriter w(outpdf, outfile.c_str()); | 2040 | QPDFWriter w(outpdf, outfile.c_str()); |
| 2034 | set_writer_options(outpdf, o, w); | 2041 | set_writer_options(outpdf, o, w); |
| 2035 | w.write(); | 2042 | w.write(); |
| 2043 | + if (o.verbose) | ||
| 2044 | + { | ||
| 2045 | + std::cout << whoami << ": wrote file " << outfile << std::endl; | ||
| 2046 | + } | ||
| 2036 | } | 2047 | } |
| 2037 | } | 2048 | } |
| 2038 | else | 2049 | else |
| @@ -2044,6 +2055,11 @@ static void write_outfile(QPDF& pdf, Options& o) | @@ -2044,6 +2055,11 @@ static void write_outfile(QPDF& pdf, Options& o) | ||
| 2044 | QPDFWriter w(pdf, o.outfilename); | 2055 | QPDFWriter w(pdf, o.outfilename); |
| 2045 | set_writer_options(pdf, o, w); | 2056 | set_writer_options(pdf, o, w); |
| 2046 | w.write(); | 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,8 +325,8 @@ $td->runtest("check obj0.pdf", | ||
| 325 | 325 | ||
| 326 | # Min/Force version | 326 | # Min/Force version |
| 327 | $td->runtest("set min version", | 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 | $td->EXIT_STATUS => 0}, | 330 | $td->EXIT_STATUS => 0}, |
| 331 | $td->NORMALIZE_NEWLINES); | 331 | $td->NORMALIZE_NEWLINES); |
| 332 | $td->runtest("check version", | 332 | $td->runtest("check version", |
| @@ -730,8 +730,8 @@ for (@sp_cases) | @@ -730,8 +730,8 @@ for (@sp_cases) | ||
| 730 | 730 | ||
| 731 | $td->runtest("split page group > 1", | 731 | $td->runtest("split page group > 1", |
| 732 | {$td->COMMAND => "qpdf --static-id --split-pages=5 11-pages.pdf" . | 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 | $td->NORMALIZE_NEWLINES); | 735 | $td->NORMALIZE_NEWLINES); |
| 736 | foreach my $f ('01-05', '06-10', '11-11') | 736 | foreach my $f ('01-05', '06-10', '11-11') |
| 737 | { | 737 | { |
qpdf/qtest/qpdf/split-pages-group.out
0 → 100644