Hi, when help is displayed, for options that require values we show their type. With string enumerations this does not really help to the user as it is unclear what are the values of the enumeration.
Attached patch fixes it by providing nicer list of possible values. https://fedorahosted.org/freeipa/ticket/1848 As result, instead of what is shown in the ticket: ------------------------------------------------------------ [root@kungfupanda ~]# ipa help hbacrule-add Purpose: Create a new HBAC rule. Usage: ipa [global-options] hbacrule-add NAME [options] Options: -h, --help show this help message and exit --usercat=STRENUM User category the rule applies to --hostcat=STRENUM Host category the rule applies to --srchostcat=STRENUM Source host category the rule applies to --servicecat=STRENUM Service category the rule applies to ------------------------------------------------------------- one would get following: ------------------------------------------------------------ [root@kungfupanda ~]# ipa help hbacrule-add Purpose: Create a new HBAC rule. Usage: ipa [global-options] hbacrule-add NAME [options] Options: -h, --help show this help message and exit --usercat=['all'] User category the rule applies to --hostcat=['all'] Host category the rule applies to --srchostcat=['all'] Source host category the rule applies to --servicecat=['all'] Service category the rule applies to ------------------------------------------------------------ It becomes even more reasonable with type or class options -- overall we have 65 StrEnums in current set of options. For example, in dnsrecord-add --class option was shown as --class=STRENUM DNS class With the patch attached it will be more understandable: ------------------------------------------------------------ [root@host3 ~]# ipa help dnsrecord-add Purpose: Add new DNS resource record. Usage: ipa [global-options] dnsrecord-add DNSZONE NAME [options] Options: -h, --help show this help message and exit --ttl=INT Time to live --class=['IN', 'CS', 'CH', 'HS'] DNS class --addattr=STR Add an attribute/value pair. Format is attr=value. The attribute must be part of the schema. --setattr=STR Set an attribute to a name/value pair. Format is attr=value. For multi-valued attributes, the command replaces the values already present. ------------------------------------------------------------ -- / Alexander Bokovoy
>From 911c0bbdbd137347e62e72384f1cd516d29dfec3 Mon Sep 17 00:00:00 2001 From: Alexander Bokovoy <[email protected]> Date: Tue, 4 Oct 2011 15:17:58 +0300 Subject: [PATCH] Unroll StrEnum values when displaying help https://fedorahosted.org/freeipa/ticket/1848 --- ipalib/cli.py | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-) diff --git a/ipalib/cli.py b/ipalib/cli.py index 0a7d1a4cf30352198eebcc7ff65bcc16f948cda7..1c34d6939285b2dcae522c13be13dc4d9f23dc57 100644 --- a/ipalib/cli.py +++ b/ipalib/cli.py @@ -48,7 +48,7 @@ import plugable import util from errors import PublicError, CommandError, HelpError, InternalError, NoSuchNamespaceError, ValidationError, NotFound, NotConfiguredError from constants import CLI_TAB -from parameters import Password, Bytes, File, Str +from parameters import Password, Bytes, File, Str, StrEnum from text import _ from ipapython.version import API_VERSION @@ -1008,8 +1008,11 @@ 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) else: kw['metavar'] = 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) else: -- 1.7.6.4
_______________________________________________ Freeipa-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/freeipa-devel
