Exemplo n.º 1
0
 def __init__(self, name, function, **kwargs):
     CommandVerb.__init__(self, name, function, **kwargs)
     self.modifiers = utility.kwargs_get_list(kwargs, 'modifiers', default = [])
     if not self.modifiers:
         utility.abort('Multi-command "%s" must provide a "modifiers" list.' % self.name)
     valid_modifiers = '|'.join([mod.name for mod in self.modifiers])
     has_args = 0
     rows = []
     for mod in self.modifiers:
         if mod.arg_name:
             usage = '%s %s [ %s ... ]' % (self.name, mod.name, mod.arg_name)
             has_args += 1
         else:
             usage = '%s %s' % (self.name, mod.name)
         rows.append((usage, mod.description))
     caption = '"%s" Command Variations' % self.name
     other_info = utility.format_table(rows, caption = caption, separator = '  ')
     self.set_defaults(other_info = other_info.strip())
     args = [
         cli.StringArgument('modifier',
                            'command modifier (valid modifiers: %s)' % valid_modifiers)]
     if has_args > 0:
         if has_args == len(self.modifiers):
             arg_desc = 'optional arguments(s)'
         else:
             arg_desc = 'optional arguments(s) (where applicable)'
         args.append(cli.StringArgument('arg', arg_desc, min_count = 0, max_count = None))
     self.add_arguments(*args)
Exemplo n.º 2
0
 def __init__(self, name, function, **kwargs):
     BaseVerb.__init__(self, name, **kwargs)
     self.function = function
     self.bundles = utility.kwargs_get_list(kwargs, 'bundles')
     # Allow the bundles to adjust options.
     for bundle in self.bundles:
         bundle.initialize(self)
Exemplo n.º 3
0
 def __init__(self, name, function, **kwargs):
     BaseVerb.__init__(self, name, **kwargs)
     self.function = function
     self.bundles = utility.kwargs_get_list(kwargs, 'bundles')
     # Allow the bundles to adjust options.
     for bundle in self.bundles:
         bundle.initialize(self)
Exemplo n.º 4
0
 def __init__(self, name, function, **kwargs):
     BaseVerb.__init__(self, name, **kwargs)
     self.function = function
     self.bundles = utility.kwargs_get_list(kwargs, 'bundles')
     # Allow the bundles to adjust options.
     for bundle in self.bundles:
         bundle.initialize(self)
     self.add_options(cli.BooleanOption(None, '--dry-run', 'dryrun', None))