mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[fix] Small issue with optional arguments... c.f. issue 1261
This commit is contained in:
parent
fad3edf66a
commit
0bd781be47
1 changed files with 11 additions and 7 deletions
|
@ -2257,13 +2257,17 @@ def _parse_action_args_in_yunohost_format(args, action_args, auth=None):
|
|||
elif arg_default is not None:
|
||||
arg_value = arg_default
|
||||
|
||||
# Validate argument value
|
||||
if (arg_value is None or arg_value == '') \
|
||||
and not arg.get('optional', False):
|
||||
raise YunohostError('app_argument_required', name=arg_name)
|
||||
elif arg_value is None:
|
||||
args_dict[arg_name] = ''
|
||||
continue
|
||||
# If the value is empty (none or '')
|
||||
# then check if arg is optional or not
|
||||
if arg_value is None or arg_value == '':
|
||||
if arg.get("optional", False):
|
||||
# Argument is optional, keep an empty value
|
||||
# and that's all for this arg !
|
||||
args_dict[arg_name] = ''
|
||||
continue
|
||||
else:
|
||||
# The argument is required !
|
||||
raise YunohostError('app_argument_required', name=arg_name)
|
||||
|
||||
# Validate argument choice
|
||||
if arg_choices and arg_value not in arg_choices:
|
||||
|
|
Loading…
Add table
Reference in a new issue