From 84c401f7d605cde6d0ca1429a7fc4c2ef65a38e1 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Tue, 18 Mar 2014 10:22:17 +0100 Subject: [PATCH] cli: Show list of values in --help for all Enums Previously only the StrEnum param type had the list of values listed in the help. Extend the functionality to any kind of Enum. --- ipalib/cli.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ipalib/cli.py b/ipalib/cli.py index a9acde3bd..19f27b17a 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -47,7 +47,7 @@ from errors import (PublicError, CommandError, HelpError, InternalError, NoSuchNamespaceError, ValidationError, NotFound, NotConfiguredError, PromptFailed) from constants import CLI_TAB -from parameters import File, Str, StrEnum, Any +from parameters import File, Str, Enum, Any from text import _ from ipapython.version import API_VERSION @@ -1117,10 +1117,10 @@ class cli(backend.Executioner): kw['action'] = 'store_false' else: kw['action'] = 'store_true' - elif isinstance(option, StrEnum): - kw['metavar'] = metavar=map(lambda x: str(x), option.values) + elif isinstance(option, Enum): + kw['metavar'] = list(str(x) for x in option.values) else: - kw['metavar'] = metavar=option.__class__.__name__.upper() + kw['metavar'] = option.__class__.__name__.upper() if option.cli_short_name: o = optparse.make_option('-%s' % option.cli_short_name, '--%s' % to_cli(option.cli_name), **kw)