schema: fix param default value handling

Advertise param's default value even when `autofill` is False. When
`autofill` is False, set `alwaysask` to True in the schema, as it is
semantically equivallent and removes redundancy.

This fixes default value disappearing in CLI for some params.

https://fedorahosted.org/freeipa/ticket/4739

Reviewed-By: David Kupka <dkupka@redhat.com>
This commit is contained in:
Jan Cholasta
2016-06-22 15:15:32 +02:00
parent 7b8247a485
commit ac8e8ecdd3
2 changed files with 16 additions and 13 deletions

View File

@@ -542,23 +542,26 @@ class param(BaseParam):
'include'):
obj[key] = list(unicode(v) for v in value)
if isinstance(metaobj, Command):
if key in ('alwaysask',
'confirm'):
if key == 'alwaysask':
obj.setdefault(key, value)
elif key == 'confirm':
obj[key] = value
elif key in ('cli_metavar',
'cli_name',
'option_group'):
obj[key] = unicode(value)
elif key == 'default':
if param.autofill:
if param.multivalue:
obj[key] = [unicode(v) for v in value]
else:
obj[key] = [unicode(value)]
if param.multivalue:
obj[key] = [unicode(v) for v in value]
else:
obj[key] = [unicode(value)]
if not param.autofill:
obj['alwaysask'] = True
elif key == 'default_from':
if param.autofill:
obj['default_from_param'] = list(unicode(k)
for k in value.keys)
obj['default_from_param'] = list(unicode(k)
for k in value.keys)
if not param.autofill:
obj['alwaysask'] = True
elif key in ('exponential',
'normalizer',
'only_absolute',