Commit 499eb088 authored by Iustin Pop's avatar Iustin Pop
Browse files

Add a new CLI option type 'list'

This simply splits the value in the option parser, instead of needing
to do it in the client code.
Signed-off-by: default avatarIustin Pop <>
Reviewed-by: default avatarRené Nussbaumer <>
parent 363c0106
......@@ -582,6 +582,18 @@ def check_bool(option, opt, value): # pylint: disable=W0613
raise errors.ParameterError("Invalid boolean value '%s'" % value)
def check_list(option, opt, value): # pylint: disable=W0613
"""Custom parser for comma-separated lists.
# we have to make this explicit check since "".split(",") is [""],
# not an empty list :(
if not value:
return []
return utils.UnescapeAndSplit(value)
# completion_suggestion is normally a list. Using numeric values not evaluating
# to False for dynamic completion.
......@@ -615,12 +627,14 @@ class CliOption(Option):
TYPE_CHECKER["identkeyval"] = check_ident_key_val
TYPE_CHECKER["keyval"] = check_key_val
TYPE_CHECKER["unit"] = check_unit
TYPE_CHECKER["bool"] = check_bool
TYPE_CHECKER["list"] = check_list
# sets make_option, so we do it for our own option class, too
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment