Passed
Push — master ( 1ac98c...ed1e15 )
by P.R.
01:49
created

BaseCommand.__set_style()   A

Complexity

Conditions 1

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
crap 1
1
"""
2
SDoc
3
4
Copyright 2016 Set Based IT Consultancy
5
6
Licence MIT
7
"""
8 1
from cleo import Command
9 1
from cleo.styles import CleoStyle
10
11
12 1
class BaseCommand(Command):
13
    """
14
    Abstract parent command for all out commands.
15
    """
16
17
    # ------------------------------------------------------------------------------------------------------------------
18 1
    def __init__(self, name=None):
19
        """
20
        Object constructor.
21
22
        :param str|None name: The name of the command.
23
        """
24 1
        Command.__init__(self, name)
25
26
    # ------------------------------------------------------------------------------------------------------------------
27 1
    def __set_style(self):
28
        """
29
        Sets the output format style used by SDoc.
30
        """
31
        # Style for file system objects (e.g. file and directory names).
32 1
        self.set_style('fso', fg='green', options=['bold'])
33
34
        # Style for errors.
35 1
        self.set_style('error', fg='red', options=['bold'])
36
37
        # Style for SDoc1 notices.
38 1
        self.set_style('notice', fg='yellow')
39
40
    # ------------------------------------------------------------------------------------------------------------------
41 1
    def execute(self, i, o):
42 1
        self.input = i
43 1
        self.output = o
44
45 1
        self.__set_style()
46 1
        self.output = CleoStyle(self.input, self.output)
47
48 1
        return self.handle()
49
50
# ----------------------------------------------------------------------------------------------------------------------
51