|
1
|
1 |
|
from cleo.application import Application |
|
2
|
|
|
from cleo.io.io import IO |
|
3
|
1 |
|
from cleo.io.outputs.output import Verbosity |
|
4
|
|
|
from pystratum_backend.StratumIO import StratumIO |
|
5
|
1 |
|
|
|
6
|
1 |
|
from pystratum_cli.command.ConstantsCommand import ConstantsCommand |
|
7
|
1 |
|
from pystratum_cli.command.RoutineLoaderCommand import RoutineLoaderCommand |
|
8
|
1 |
|
from pystratum_cli.command.RoutineWrapperCommand import RoutineWrapperCommand |
|
9
|
|
|
from pystratum_cli.command.StratumCommand import StratumCommand |
|
10
|
|
|
|
|
11
|
1 |
|
|
|
12
|
|
|
class StratumApplication(Application): |
|
13
|
|
|
""" |
|
14
|
|
|
The PyStratum application. |
|
15
|
|
|
""" |
|
16
|
|
|
|
|
17
|
1 |
|
# ------------------------------------------------------------------------------------------------------------------ |
|
18
|
|
|
def __init__(self): |
|
19
|
|
|
""" |
|
20
|
|
|
Object constructor |
|
21
|
1 |
|
""" |
|
22
|
|
|
Application.__init__(self, 'pystratum', '1.0.4') |
|
23
|
|
|
|
|
24
|
1 |
|
self.add(ConstantsCommand()) |
|
25
|
|
|
self.add(RoutineLoaderCommand()) |
|
26
|
|
|
self.add(StratumCommand()) |
|
27
|
|
|
self.add(RoutineWrapperCommand()) |
|
28
|
|
|
|
|
29
|
|
|
# ------------------------------------------------------------------------------------------------------------------ |
|
30
|
1 |
|
def render_error(self, error: Exception, io: IO) -> None: |
|
31
|
|
|
if io.output.verbosity == Verbosity.NORMAL: |
|
32
|
1 |
|
my_io = StratumIO(io.input, io.output, io.error_output) |
|
33
|
1 |
|
lines = [error.__class__.__name__, str(error)] |
|
34
|
1 |
|
my_io.error(lines) |
|
35
|
1 |
|
else: |
|
36
|
|
|
Application.render_error(self, error, io) |
|
37
|
1 |
|
|
|
38
|
|
|
# ---------------------------------------------------------------------------------------------------------------------- |
|
39
|
|
|
|