python: Allow optional multi-value arguements for samba-tool commands
authorAndrew Bartlett <abartlet@samba.org>
Wed, 24 Feb 2016 23:42:09 +0000 (12:42 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Thu, 25 Feb 2016 03:48:18 +0000 (04:48 +0100)
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
python/samba/netcmd/__init__.py

index a3edf50516567527a6fb226357b463e9f97ca285..1debae8c39f4a2adb86fa8cbba980048726b9b30 100644 (file)
@@ -153,13 +153,14 @@ class Command(object):
         # Check for a min a max number of allowed arguments, whenever possible
         # The suffix "?" means zero or one occurence
         # The suffix "+" means at least one occurence
+        # The suffix "*" means zero or more occurences
         min_args = 0
         max_args = 0
         undetermined_max_args = False
         for i, arg in enumerate(self.takes_args):
-            if arg[-1] != "?":
+            if arg[-1] != "?" and arg[-1] != "*":
                min_args += 1
-            if arg[-1] == "+":
+            if arg[-1] == "+" or arg[-1] == "*":
                undetermined_max_args = True
             else:
                max_args += 1