|
|
@ -4,10 +4,12 @@ |
|
|
|
class Command(object): |
|
|
|
class Command(object): |
|
|
|
"""A command line statement.""" |
|
|
|
"""A command line statement.""" |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, statement, comment=None, condition=None, cd=None, environments=None, function=None, prefix=None, |
|
|
|
def __init__(self, statement, comment=None, condition=None, cd=None, environments=None, function=None, name=None, |
|
|
|
register=None, shell=None, stop=False, sudo=None, tags=None, **kwargs): |
|
|
|
prefix=None, register=None, shell=None, stop=False, sudo=None, tags=None, **kwargs): |
|
|
|
"""Initialize a command. |
|
|
|
"""Initialize a command. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:param name: The name of the command. |
|
|
|
|
|
|
|
|
|
|
|
:param statement: The statement to be executed. |
|
|
|
:param statement: The statement to be executed. |
|
|
|
:type statement: str |
|
|
|
:type statement: str |
|
|
|
|
|
|
|
|
|
|
@ -26,6 +28,10 @@ class Command(object): |
|
|
|
:param function: The name of the function in which the statement is executed. |
|
|
|
:param function: The name of the function in which the statement is executed. |
|
|
|
:type function: str |
|
|
|
:type function: str |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:param name: The name of the command from the mapping. Not used and not required for programmatic use, but |
|
|
|
|
|
|
|
automatically assigned during factory instantiation. |
|
|
|
|
|
|
|
:type name: str |
|
|
|
|
|
|
|
|
|
|
|
:param prefix: A statement to execute before the main statement is executed. |
|
|
|
:param prefix: A statement to execute before the main statement is executed. |
|
|
|
:type prefix: str |
|
|
|
:type prefix: str |
|
|
|
|
|
|
|
|
|
|
@ -53,6 +59,7 @@ class Command(object): |
|
|
|
self.cd = cd |
|
|
|
self.cd = cd |
|
|
|
self.environments = environments or list() |
|
|
|
self.environments = environments or list() |
|
|
|
self.function = function |
|
|
|
self.function = function |
|
|
|
|
|
|
|
self.name = name |
|
|
|
self.prefix = prefix |
|
|
|
self.prefix = prefix |
|
|
|
self.register = register |
|
|
|
self.register = register |
|
|
|
self.shell = shell |
|
|
|
self.shell = shell |
|
|
@ -143,7 +150,7 @@ class Command(object): |
|
|
|
class ItemizedCommand(object): |
|
|
|
class ItemizedCommand(object): |
|
|
|
"""An itemized command represents multiple commands of with the same statement but different parameters.""" |
|
|
|
"""An itemized command represents multiple commands of with the same statement but different parameters.""" |
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, callback, items, *args, **kwargs): |
|
|
|
def __init__(self, callback, items, *args, name=None, **kwargs): |
|
|
|
"""Initialize the command. |
|
|
|
"""Initialize the command. |
|
|
|
|
|
|
|
|
|
|
|
:param callback: The function to be used to generate the command. |
|
|
|
:param callback: The function to be used to generate the command. |
|
|
@ -151,6 +158,10 @@ class ItemizedCommand(object): |
|
|
|
:param items: The command arguments. |
|
|
|
:param items: The command arguments. |
|
|
|
:type items: list[str] |
|
|
|
:type items: list[str] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
:param name: The name of the command from the mapping. Not used and not required for programmatic use, but |
|
|
|
|
|
|
|
automatically assigned during factory instantiation. |
|
|
|
|
|
|
|
:type name: str |
|
|
|
|
|
|
|
|
|
|
|
:param args: The itemized arguments. ``$item`` should be included. |
|
|
|
:param args: The itemized arguments. ``$item`` should be included. |
|
|
|
|
|
|
|
|
|
|
|
:param kwargs: Keyword arguments are passed to the command class upon instantiation. |
|
|
|
:param kwargs: Keyword arguments are passed to the command class upon instantiation. |
|
|
@ -160,6 +171,7 @@ class ItemizedCommand(object): |
|
|
|
self.callback = callback |
|
|
|
self.callback = callback |
|
|
|
self.items = items |
|
|
|
self.items = items |
|
|
|
self.kwargs = kwargs |
|
|
|
self.kwargs = kwargs |
|
|
|
|
|
|
|
self.name = name |
|
|
|
|
|
|
|
|
|
|
|
def __getattr__(self, item): |
|
|
|
def __getattr__(self, item): |
|
|
|
return self.kwargs.get(item) |
|
|
|
return self.kwargs.get(item) |
|
|
|