diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-01-07 21:29:27 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-01-30 19:11:03 +0100 |
commit | 53ba65eb59d0bced37e73d8bf96a0d7a7285f662 (patch) | |
tree | 29049c9c37ba25ea22313b83ac93e20a0a48b74b /generate_auto_job | |
parent | a301cc5373f14fd03e51619b0bd5fad22b84e115 (diff) | |
download | qpdf-53ba65eb59d0bced37e73d8bf96a0d7a7285f662.tar.zst |
QPDFArgParser: handle optional choices including help
Handle optional choices in addition to required choices. Refactor the
way help options are added to completion to make it work with optional
help choices.
Diffstat (limited to 'generate_auto_job')
-rwxr-xr-x | generate_auto_job | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/generate_auto_job b/generate_auto_job index 7e70d29c..2dc51105 100755 --- a/generate_auto_job +++ b/generate_auto_job @@ -119,7 +119,7 @@ class Main: self.check_keys('top', o, set( ['table', 'prefix', 'bare', 'positional', 'optional_parameter', 'required_parameter', - 'required_choices', 'from_table'])) + 'required_choices', 'optional_choices', 'from_table'])) def to_identifier(self, label, prefix, const): identifier = re.sub(r'[^a-zA-Z0-9]', '_', label) @@ -157,6 +157,9 @@ class Main: for i in o.get('required_choices', {}): identifier = self.to_identifier(i, prefix, False) print(f'void {identifier}(char *);', file=f) + for i in o.get('optional_choices', {}): + identifier = self.to_identifier(i, prefix, False) + print(f'void {identifier}(char *);', file=f) if table not in ('main', 'help'): identifier = self.to_identifier(table, 'argEnd', False) print(f'void {identifier}();', file=f) @@ -204,9 +207,14 @@ class Main: f', "{v}");', file=f) for k, v in o.get('required_choices', {}).items(): identifier = self.to_identifier(k, prefix, False) - print(f'this->ap.addRequiredChoices("{k}", ' + print(f'this->ap.addChoices("{k}", ' + f'p(&ArgParser::{identifier})' + f', true, {v}_choices);', file=f) + for k, v in o.get('optional_choices', {}).items(): + identifier = self.to_identifier(k, prefix, False) + print(f'this->ap.addChoices("{k}", ' f'p(&ArgParser::{identifier})' - f', {v}_choices);', file=f) + f', false, {v}_choices);', file=f) for o in data['options']: table = o['table'] if 'from_table' not in o: |