summaryrefslogtreecommitdiffstats
path: root/ipalib/public.py
diff options
context:
space:
mode:
Diffstat (limited to 'ipalib/public.py')
-rw-r--r--ipalib/public.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/ipalib/public.py b/ipalib/public.py
index c44d039d..8ca97a36 100644
--- a/ipalib/public.py
+++ b/ipalib/public.py
@@ -236,6 +236,9 @@ class Command(plugable.Plugin):
def __init__(self):
self.args = plugable.NameSpace(self.__check_args(), sort=False)
self.options = plugable.NameSpace(self.__check_options(), sort=False)
+ self.params = plugable.NameSpace(
+ tuple(self.args()) + tuple(self.options()), sort=False
+ )
def get_args(self):
return self.takes_args
@@ -347,6 +350,32 @@ class Command(plugable.Plugin):
for option in sorted(self.options(), key=get_key):
yield option
+ def args_to_kw(self, *args):
+ Args = tuple(self.args())
+ if len(args) > len(Args):
+ if len(Args) > 0 and not Args[-1].multivalue:
+ if len(Args) == 1:
+ error = 'takes at most 1 argument'
+ else:
+ error = 'takes at most %d arguments' % len(Args)
+ raise errors.ArgumentError(self, error)
+ else:
+ raise errors.ArgumentError(self, 'takes no arguments')
+ MinArgs = sum(int(A.required) for A in Args)
+ if len(args) < MinArgs:
+ if MinArgs == 1:
+ error = 'takes at least 1 argument'
+ else:
+ error = 'takes at least %d arguments' % MinArgs
+ raise errors.ArgumentError(self, error)
+ for (i, Arg) in enumerate(Args):
+ pass
+
+
+
+
+
+
class Object(plugable.Plugin):