diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-02-01 00:15:10 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-02-01 00:16:09 +0100 |
commit | 21b9290785fb03477784cf6312f57cfb96dbe53d (patch) | |
tree | ba51fcff3ed2982623d4ce9cd88c490eee34f95d /generate_auto_job | |
parent | ea96330bb615791de58a4f6beb6203137fe1ba35 (diff) | |
download | qpdf-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-x | generate_auto_job | 13 |
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): |