aboutsummaryrefslogtreecommitdiffstats
path: root/generate_auto_job
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2022-02-01 00:15:10 +0100
committerJay Berkenbilt <ejb@ql.org>2022-02-01 00:16:09 +0100
commit21b9290785fb03477784cf6312f57cfb96dbe53d (patch)
treeba51fcff3ed2982623d4ce9cd88c490eee34f95d /generate_auto_job
parentea96330bb615791de58a4f6beb6203137fe1ba35 (diff)
downloadqpdf-21b9290785fb03477784cf6312f57cfb96dbe53d.tar.zst
QPDFJob json: make bare arguments expect the empty string
Changing from bool requiring true to string requiring the empty string is more consistent with the CLI and makes it possible to add an optional parameter or choices later without breaking compatibility.
Diffstat (limited to 'generate_auto_job')
-rwxr-xr-xgenerate_auto_job13
1 files changed, 9 insertions, 4 deletions
diff --git a/generate_auto_job b/generate_auto_job
index 5993a48e..68fa269d 100755
--- a/generate_auto_job
+++ b/generate_auto_job
@@ -465,14 +465,19 @@ class Main:
self.json_init.append(
f'addBare([this]() {{ {config}->{flag_key}(); }});')
elif kind == 'optional_parameter' or kind == 'required_parameter':
- # No optional parameters in json
+ # Optional parameters end up just being the empty string,
+ # so the handler has to deal with it. The empty string is
+ # also allowed for non-optional.
self.json_init.append(
f'addParameter([this](char const* p)'
f' {{ {config}->{flag_key}(p); }});')
- elif kind == 'optional_choices' or kind == 'required_choices':
- # No optional choices in json
+ elif kind == 'optional_choices':
+ self.json_init.append(
+ f'addChoices({v}_choices, false,'
+ f' [this](char const* p) {{ {config}->{flag_key}(p); }});')
+ elif kind == 'required_choices':
self.json_init.append(
- f'addChoices({v}_choices,'
+ f'addChoices({v}_choices, true,'
f' [this](char const* p) {{ {config}->{flag_key}(p); }});')
def handle_json_manual(self, path):