From 21b9290785fb03477784cf6312f57cfb96dbe53d Mon Sep 17 00:00:00 2001 From: Jay Berkenbilt Date: Mon, 31 Jan 2022 18:15:10 -0500 Subject: 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. --- generate_auto_job | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'generate_auto_job') 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): -- cgit v1.2.3-54-g00ecf