aboutsummaryrefslogtreecommitdiffstats
path: root/libqpdf
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-05-06 23:29:22 +0200
committerJay Berkenbilt <ejb@ql.org>2022-05-07 14:26:31 +0200
commitb361c5ce19a05ce8da60c767651521a9ce0210e5 (patch)
tree393a50f550bc03a79d74a9b8bc12635215a53dcd /libqpdf
parent7604ac5cb2a4756337ed562d2e3284de3e6a8159 (diff)
downloadqpdf-b361c5ce19a05ce8da60c767651521a9ce0210e5.tar.zst
Add --test-json-schema command-line option
Diffstat (limited to 'libqpdf')
-rw-r--r--libqpdf/QPDFJob.cc1
-rw-r--r--libqpdf/QPDFJob_config.cc7
-rw-r--r--libqpdf/qpdf/auto_job_help.hh7
-rw-r--r--libqpdf/qpdf/auto_job_init.hh1
-rw-r--r--libqpdf/qpdf/auto_job_json_init.hh3
-rw-r--r--libqpdf/qpdf/auto_job_schema.hh1
6 files changed, 20 insertions, 0 deletions
diff --git a/libqpdf/QPDFJob.cc b/libqpdf/QPDFJob.cc
index 0b35a289..1e456f24 100644
--- a/libqpdf/QPDFJob.cc
+++ b/libqpdf/QPDFJob.cc
@@ -400,6 +400,7 @@ QPDFJob::Members::Members() :
flatten_rotation(false),
list_attachments(false),
json_version(0),
+ test_json_schema(false),
check(false),
optimize_images(false),
externalize_inline_images(false),
diff --git a/libqpdf/QPDFJob_config.cc b/libqpdf/QPDFJob_config.cc
index 032a6492..621499c1 100644
--- a/libqpdf/QPDFJob_config.cc
+++ b/libqpdf/QPDFJob_config.cc
@@ -261,6 +261,13 @@ QPDFJob::Config::jsonObject(std::string const& parameter)
}
QPDFJob::Config*
+QPDFJob::Config::testJsonSchema()
+{
+ o.m->test_json_schema = true;
+ return this;
+}
+
+QPDFJob::Config*
QPDFJob::Config::keepFilesOpen(std::string const& parameter)
{
o.m->keep_files_open_set = true;
diff --git a/libqpdf/qpdf/auto_job_help.hh b/libqpdf/qpdf/auto_job_help.hh
index 388b861f..55d2cc63 100644
--- a/libqpdf/qpdf/auto_job_help.hh
+++ b/libqpdf/qpdf/auto_job_help.hh
@@ -835,6 +835,12 @@ Write the first pass of linearization to the named file. The
resulting file is not a valid PDF file. This option is useful only
for debugging qpdf.
)");
+ap.addOptionHelp("--test-json-schema", "testing", "test generated json against schema", R"(This is used by qpdf's test suite to check consistency between
+the output of qpdf --json and the output of qpdf --json-help.
+)");
+}
+static void add_help_8(QPDFArgParser& ap)
+{
}
static void add_help(QPDFArgParser& ap)
{
@@ -845,6 +851,7 @@ static void add_help(QPDFArgParser& ap)
add_help_5(ap);
add_help_6(ap);
add_help_7(ap);
+ add_help_8(ap);
ap.addHelpFooter("For detailed help, visit the qpdf manual: https://qpdf.readthedocs.io\n");
}
diff --git a/libqpdf/qpdf/auto_job_init.hh b/libqpdf/qpdf/auto_job_init.hh
index 5483cbb2..74155b80 100644
--- a/libqpdf/qpdf/auto_job_init.hh
+++ b/libqpdf/qpdf/auto_job_init.hh
@@ -77,6 +77,7 @@ this->ap.addBare("static-aes-iv", [this](){c_main->staticAesIv();});
this->ap.addBare("static-id", [this](){c_main->staticId();});
this->ap.addBare("suppress-password-recovery", [this](){c_main->suppressPasswordRecovery();});
this->ap.addBare("suppress-recovery", [this](){c_main->suppressRecovery();});
+this->ap.addBare("test-json-schema", [this](){c_main->testJsonSchema();});
this->ap.addBare("underlay", b(&ArgParser::argUnderlay));
this->ap.addBare("verbose", [this](){c_main->verbose();});
this->ap.addBare("warning-exit-0", [this](){c_main->warningExit0();});
diff --git a/libqpdf/qpdf/auto_job_json_init.hh b/libqpdf/qpdf/auto_job_json_init.hh
index 3c83ec2d..b2516469 100644
--- a/libqpdf/qpdf/auto_job_json_init.hh
+++ b/libqpdf/qpdf/auto_job_json_init.hh
@@ -267,6 +267,9 @@ popHandler(); // key: noWarn
pushKey("verbose");
addBare([this]() { c_main->verbose(); });
popHandler(); // key: verbose
+pushKey("testJsonSchema");
+addBare([this]() { c_main->testJsonSchema(); });
+popHandler(); // key: testJsonSchema
pushKey("ignoreXrefStreams");
addBare([this]() { c_main->ignoreXrefStreams(); });
popHandler(); // key: ignoreXrefStreams
diff --git a/libqpdf/qpdf/auto_job_schema.hh b/libqpdf/qpdf/auto_job_schema.hh
index 557af9ee..267dad23 100644
--- a/libqpdf/qpdf/auto_job_schema.hh
+++ b/libqpdf/qpdf/auto_job_schema.hh
@@ -89,6 +89,7 @@ static constexpr char const* JOB_SCHEMA_DATA = R"({
"keepFilesOpenThreshold": "set threshold for keepFilesOpen",
"noWarn": "suppress printing of warning messages",
"verbose": "print additional information",
+ "testJsonSchema": "test generated json against schema",
"ignoreXrefStreams": "use xref tables rather than streams",
"passwordIsHexKey": "provide hex-encoded encryption key",
"passwordMode": "tweak how qpdf encodes passwords",