From d6e1e15fcd6eb924320fdb8f3d8138aba9eae0c3 Mon Sep 17 00:00:00 2001 From: Rob Crittenden Date: Wed, 10 Jun 2009 15:07:24 -0400 Subject: Add a one-character option for parameters --- ipalib/parameters.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'ipalib/parameters.py') diff --git a/ipalib/parameters.py b/ipalib/parameters.py index e805172a..d9e33f8a 100644 --- a/ipalib/parameters.py +++ b/ipalib/parameters.py @@ -221,6 +221,7 @@ class Param(ReadOnly): kwargs = ( ('cli_name', str, None), + ('cli_short_name', str, None), ('label', callable, None), ('doc', str, ''), ('required', bool, True), @@ -260,6 +261,13 @@ class Param(ReadOnly): self.name = check_name(name) self.nice = '%s(%r)' % (self.__class__.__name__, self.param_spec) + if 'cli_short_name' in kw: + if len(kw['cli_short_name']) != 1: + raise TypeError( + '%s: cli_short_name can only be a single character: %s' + % (self.nice, kw['cli_short_name']) + ) + # Add 'default' to self.kwargs and makes sure no unknown kw were given: assert type(self.type) is type if kw.get('multivalue', True): -- cgit