aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qpdf/qpdf.cc20
-rw-r--r--qpdf/qtest/qpdf.test7
2 files changed, 21 insertions, 6 deletions
diff --git a/qpdf/qpdf.cc b/qpdf/qpdf.cc
index 74285bcd..a23d640f 100644
--- a/qpdf/qpdf.cc
+++ b/qpdf/qpdf.cc
@@ -225,6 +225,9 @@ provided last take precedence.\n\
Basic Options\n\
-------------\n\
\n\
+--version show version of qpdf\n\
+--copyright show qpdf's copyright and license information\n\
+--help show command-line argument help\n\
--password=password specify a password for accessing encrypted files\n\
--verbose provide additional informational output\n\
--linearize generated a linearized (web optimized) file\n\
@@ -1188,16 +1191,23 @@ static void read_args_from_file(char const* filename,
static void handle_help_version(int argc, char* argv[])
{
+ // Make sure the outpu looks right on an 80-column display.
+
if ((argc == 2) &&
((strcmp(argv[1], "--version") == 0) ||
(strcmp(argv[1], "-version") == 0)))
{
- // make_dist looks for the line of code here that actually
- // prints the version number, so read make_dist if you change
- // anything other than the version number. Don't worry about
- // the numbers. That's just a guide to 80 columns so that the
- // help message looks right on an 80-column display.
+ std::cout
+ << whoami << " version " << QPDF::QPDFVersion() << std::endl
+ << "Run " << whoami << " --copyright to see copyright and license information."
+ << std::endl;
+ exit(0);
+ }
+ if ((argc == 2) &&
+ ((strcmp(argv[1], "--copyright") == 0) ||
+ (strcmp(argv[1], "-copyright") == 0)))
+ {
// 1 2 3 4 5 6 7 8
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890
std::cout
diff --git a/qpdf/qtest/qpdf.test b/qpdf/qtest/qpdf.test
index 9e6c1a87..c6e39fb8 100644
--- a/qpdf/qtest/qpdf.test
+++ b/qpdf/qtest/qpdf.test
@@ -250,12 +250,17 @@ foreach my $d (@bug_tests)
show_ntests();
# ----------
$td->notify("--- Library version ---");
-$n_tests += 2;
+$n_tests += 3;
$td->runtest("qpdf version",
{$td->COMMAND => "qpdf --version"},
{$td->REGEXP => "qpdf version \\S+\n.*", $td->EXIT_STATUS => 0},
$td->NORMALIZE_NEWLINES);
+$td->runtest("qpdf copyright contains version too",
+ {$td->COMMAND => "qpdf --copyright"},
+ {$td->REGEXP => "(?s)qpdf version \\S+\n.*Apache.*",
+ $td->EXIT_STATUS => 0},
+ $td->NORMALIZE_NEWLINES);
$td->runtest("C API: qpdf version",
{$td->COMMAND => "qpdf-ctest --version"},
{$td->REGEXP => "qpdf-ctest version \\S+\n",