aboutsummaryrefslogtreecommitdiffstats
path: root/generate_auto_job
diff options
context:
space:
mode:
Diffstat (limited to 'generate_auto_job')
-rwxr-xr-xgenerate_auto_job14
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: