mirror of
https://github.com/qpdf/qpdf.git
synced 2024-12-22 19:08:59 +00:00
Fix --json-help to take a version parameter
This commit is contained in:
parent
69820847af
commit
80acfc3826
@ -46,6 +46,8 @@ class QPDFLogger;
|
||||
class QPDFJob
|
||||
{
|
||||
public:
|
||||
static int constexpr LATEST_JOB_JSON = 1;
|
||||
|
||||
// Exit codes -- returned by getExitCode() after calling run()
|
||||
static int constexpr EXIT_ERROR = qpdf_exit_error;
|
||||
static int constexpr EXIT_WARNING = qpdf_exit_warning;
|
||||
@ -426,14 +428,23 @@ class QPDFJob
|
||||
doIfVerbose(std::function<void(Pipeline&, std::string const& prefix)> fn);
|
||||
|
||||
// Provide a string that is the help information ("schema" for the
|
||||
// qpdf-specific JSON object) for version 1 of the JSON output.
|
||||
// qpdf-specific JSON object) for the specified version of JSON
|
||||
// output.
|
||||
QPDF_DLL
|
||||
static std::string json_out_schema_v1();
|
||||
static std::string json_out_schema(int version);
|
||||
|
||||
// Provide a string that is the help information for the version 1
|
||||
// of JSON format for QPDFJob.
|
||||
QPDF_DLL
|
||||
static std::string job_json_schema_v1();
|
||||
[[deprecated("use json_out_schema(version)")]] static std::string
|
||||
json_out_schema_v1();
|
||||
|
||||
// Provide a string that is the help information for specified
|
||||
// version of JSON format for QPDFJob.
|
||||
QPDF_DLL
|
||||
static std::string job_json_schema(int version);
|
||||
|
||||
QPDF_DLL
|
||||
[[deprecated("use job_json_schema(version)")]] static std::string
|
||||
job_json_schema_v1();
|
||||
|
||||
private:
|
||||
struct RotationSpec
|
||||
|
6
job.sums
6
job.sums
@ -6,10 +6,10 @@ include/qpdf/auto_job_c_enc.hh 28446f3c32153a52afa239ea40503e6cc8ac2c026813526a3
|
||||
include/qpdf/auto_job_c_main.hh cdba1ae6ea5525a585d10a3dd95b7996d62b17de4211fe658b78d9d463b0f313
|
||||
include/qpdf/auto_job_c_pages.hh b3cc0f21029f6d89efa043dcdbfa183cb59325b6506001c18911614fe8e568ec
|
||||
include/qpdf/auto_job_c_uo.hh ae21b69a1efa9333050f4833d465f6daff87e5b38e5106e49bbef5d4132e4ed1
|
||||
job.yml ad7c086267fe6f309bf0838840f22cbd95326259cad148b4d5e6699b49f5f379
|
||||
libqpdf/qpdf/auto_job_decl.hh 74df4d7fdbdf51ecd0d58ce1e9844bb5525b9adac5a45f7c9a787ecdda2868df
|
||||
job.yml f9564f18b08a45d17328af43652645771d3498471820c858b8c9013a193e1412
|
||||
libqpdf/qpdf/auto_job_decl.hh 7844eba58edffb9494b19e8eca6fd59a24d6e152ca606c3b07da569f753df2da
|
||||
libqpdf/qpdf/auto_job_help.hh db2e4350c700e064b204e3e20d4fee4eddfe312b28092afcf608b4b6863d30e5
|
||||
libqpdf/qpdf/auto_job_init.hh 3c3576b6d1d79fda64ae53f08fd9fd2b42c86f3c1d52dd4db0d7f2d4d64b9b4a
|
||||
libqpdf/qpdf/auto_job_init.hh fd1635a5ad6ba16b7ae008467145560a59a5ecfd10d29c5ef7cd0d8347747cd2
|
||||
libqpdf/qpdf/auto_job_json_decl.hh 06caa46eaf71db8a50c046f91866baa8087745a9474319fb7c86d92634cc8297
|
||||
libqpdf/qpdf/auto_job_json_init.hh 59545578a2e47c660ff98516ed53f06638be75eb4658e2a09d32cc08e0cb7268
|
||||
libqpdf/qpdf/auto_job_schema.hh 9d543cd4a43eafffc2c4b8a6fee29e399c271c52cb6f7d417ae5497b3c1127dc
|
||||
|
3
job.yml
3
job.yml
@ -75,9 +75,10 @@ options:
|
||||
bare:
|
||||
- version
|
||||
- copyright
|
||||
- json-help
|
||||
- show-crypto
|
||||
- job-json-help
|
||||
optional_choices:
|
||||
json-help: json_version
|
||||
- table: main
|
||||
config: c_main
|
||||
manual:
|
||||
|
@ -487,6 +487,15 @@ QPDFJob::config()
|
||||
std::string
|
||||
QPDFJob::job_json_schema_v1()
|
||||
{
|
||||
return job_json_schema(1);
|
||||
}
|
||||
|
||||
std::string
|
||||
QPDFJob::job_json_schema(int version)
|
||||
{
|
||||
if (version != LATEST_JOB_JSON) {
|
||||
throw std::runtime_error("job_json_schema: version must be 1");
|
||||
}
|
||||
return JOB_SCHEMA_DATA;
|
||||
}
|
||||
|
||||
@ -1752,6 +1761,12 @@ QPDFJob::json_schema(int json_version, std::set<std::string>* keys)
|
||||
return schema;
|
||||
}
|
||||
|
||||
std::string
|
||||
QPDFJob::json_out_schema(int version)
|
||||
{
|
||||
return json_schema(version).unparse();
|
||||
}
|
||||
|
||||
std::string
|
||||
QPDFJob::json_out_schema_v1()
|
||||
{
|
||||
|
@ -143,10 +143,17 @@ ArgParser::argCopyright()
|
||||
}
|
||||
|
||||
void
|
||||
ArgParser::argJsonHelp()
|
||||
ArgParser::argJsonHelp(std::string const& parameter)
|
||||
{
|
||||
int version = JSON::LATEST;
|
||||
if (!(parameter.empty() || (parameter == "latest"))) {
|
||||
version = QUtil::string_to_int(parameter.c_str());
|
||||
}
|
||||
if ((version < 1) || (version > JSON::LATEST)) {
|
||||
usage(std::string("unsupported json version ") + parameter);
|
||||
}
|
||||
*QPDFLogger::defaultLogger()->getInfo()
|
||||
<< QPDFJob::json_out_schema_v1() << "\n";
|
||||
<< QPDFJob::json_out_schema(version) << "\n";
|
||||
}
|
||||
|
||||
void
|
||||
@ -396,7 +403,7 @@ void
|
||||
ArgParser::argJobJsonHelp()
|
||||
{
|
||||
*QPDFLogger::defaultLogger()->getInfo()
|
||||
<< QPDFJob::job_json_schema_v1() << "\n";
|
||||
<< QPDFJob::job_json_schema(QPDFJob::LATEST_JOB_JSON) << "\n";
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
static JSON JOB_SCHEMA = JSON::parse(QPDFJob::job_json_schema_v1().c_str());
|
||||
static JSON JOB_SCHEMA = JSON::parse(QPDFJob::job_json_schema(1).c_str());
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -16,9 +16,9 @@ static constexpr char const* O_COPY_ATTACHMENT = "copy attachment";
|
||||
|
||||
void argVersion();
|
||||
void argCopyright();
|
||||
void argJsonHelp();
|
||||
void argShowCrypto();
|
||||
void argJobJsonHelp();
|
||||
void argJsonHelp(std::string const&);
|
||||
void argPositional(std::string const&);
|
||||
void argAddAttachment();
|
||||
void argCopyAttachmentsFrom();
|
||||
|
@ -29,9 +29,9 @@ static char const* modify128_choices[] = {"all", "annotate", "form", "assembly",
|
||||
this->ap.selectHelpOptionTable();
|
||||
this->ap.addBare("version", b(&ArgParser::argVersion));
|
||||
this->ap.addBare("copyright", b(&ArgParser::argCopyright));
|
||||
this->ap.addBare("json-help", b(&ArgParser::argJsonHelp));
|
||||
this->ap.addBare("show-crypto", b(&ArgParser::argShowCrypto));
|
||||
this->ap.addBare("job-json-help", b(&ArgParser::argJobJsonHelp));
|
||||
this->ap.addChoices("json-help", p(&ArgParser::argJsonHelp), false, json_version_choices);
|
||||
this->ap.selectMainOptionTable();
|
||||
this->ap.addPositional(p(&ArgParser::argPositional));
|
||||
this->ap.addBare("add-attachment", b(&ArgParser::argAddAttachment));
|
||||
|
Loading…
Reference in New Issue
Block a user