Report missing or bad manifest arg type, or unecessary 'choices' usage

This commit is contained in:
Alexandre Aubin 2019-01-28 19:26:41 +01:00
parent d37eaae1e2
commit 910a3b2006

View file

@ -231,13 +231,20 @@ def check_manifest(path):
print_warning("[YEP-2.1]" + service + " service may not exist")
if "install" in manifest["arguments"]:
types = ("domain", "path", "password", "user", "admin")
for nbr, typ in enumerate(types):
for install_arg in manifest["arguments"]["install"]:
if typ == install_arg["name"]:
if "type" not in install_arg:
print_wrong("[YEP-2.1] You should specify the type of the key with %s" % (typ))
recognized_types = ("domain", "path", "boolean", "app", "password", "user", "string")
for argument in manifest["arguments"]["install"]:
if not "type" in argument.keys():
print_wrong("[YEP-2.1] You should specify the type of the argument '%s'. You can use : %s." % (argument["name"], ', '.join(recognized_types)))
elif argument["type"] not in recognized_types:
print_warning("[YEP-2.1] The type '%s' for argument '%s' is not recognized... it probably doesn't behave as you expect ? Choose among those instead : %s" % (argument["type"], argument["name"], ', '.join(recognized_types)))
if "choices" in argument.keys():
choices = [ c.lower() for c in argument["choices"] ]
if len(choices) == 2:
if ("true" in choices and "false" in choices) or ("yes" in choices and "no" in choices):
print_warning("Argument %s : you might want to simply use a boolean-type argument. No need to specify the choices list yourself." % argument["name"])