[fix] Small issue with optional arguments... c.f. issue 1261

This commit is contained in:
Alexandre Aubin 2019-03-27 15:11:11 +01:00
parent fad3edf66a
commit 0bd781be47

View file

@ -2257,13 +2257,17 @@ def _parse_action_args_in_yunohost_format(args, action_args, auth=None):
elif arg_default is not None: elif arg_default is not None:
arg_value = arg_default arg_value = arg_default
# Validate argument value # If the value is empty (none or '')
if (arg_value is None or arg_value == '') \ # then check if arg is optional or not
and not arg.get('optional', False): if arg_value is None or arg_value == '':
raise YunohostError('app_argument_required', name=arg_name) if arg.get("optional", False):
elif arg_value is None: # Argument is optional, keep an empty value
# and that's all for this arg !
args_dict[arg_name] = '' args_dict[arg_name] = ''
continue continue
else:
# The argument is required !
raise YunohostError('app_argument_required', name=arg_name)
# Validate argument choice # Validate argument choice
if arg_choices and arg_value not in arg_choices: if arg_choices and arg_value not in arg_choices: