Coverage for src/probable_fiesta/command/builder/command.py: 100%
18 statements
« prev ^ index » next coverage.py v7.1.0, created at 2023-01-30 18:57 -0500
« prev ^ index » next coverage.py v7.1.0, created at 2023-01-30 18:57 -0500
1"""Command class."""
2class Command:
4 def __init__(self, name, function, *args):
5 self.name = name
6 self.function = function
7 self.args = args
9 def __str__(self):
10 return f"Command: {self.__dict__}"
12 def invoke(self):
13 if self.function is not None and self.args is not None:
14 if self.args[0] is not None:
15 return self.function(*self.args)
16 return self.function()
17 #elif self.function is not None and self.args is None:
18 #return self.function()
19 return None
21 class Factory():
23 @staticmethod
24 def new_command(name, function, *args):
25 return Command(name, function, *args)
27 factory = Factory()