|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This is the part of Povils open-source library. |
|
5
|
|
|
* |
|
6
|
|
|
* @author Povilas Susinskas |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Povils\Figlet\Command; |
|
10
|
|
|
|
|
11
|
|
|
use Povils\Figlet\Figlet; |
|
12
|
|
|
use Symfony\Component\Console\Command\Command; |
|
13
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
14
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
15
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
16
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Class FigletCommand |
|
20
|
|
|
* |
|
21
|
|
|
* @package Povils\Figlet\Command |
|
22
|
|
|
*/ |
|
23
|
|
|
class FigletCommand extends Command |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @inheritdoc |
|
27
|
|
|
*/ |
|
28
|
|
|
protected function configure() |
|
29
|
|
|
{ |
|
30
|
|
|
$this |
|
31
|
|
|
->setName('figlet') |
|
32
|
|
|
->setDescription('Writes figlet text in terminal') |
|
33
|
|
|
->addArgument('text', InputArgument::REQUIRED, 'Here should be figlet text') |
|
34
|
|
|
->addOption( |
|
35
|
|
|
'font', |
|
36
|
|
|
'f', |
|
37
|
|
|
InputOption::VALUE_OPTIONAL, |
|
38
|
|
|
'Figlet font', |
|
39
|
|
|
'big' |
|
40
|
|
|
) |
|
41
|
|
|
->addOption( |
|
42
|
|
|
'color', |
|
43
|
|
|
'c', |
|
44
|
|
|
InputOption::VALUE_OPTIONAL, |
|
45
|
|
|
'Figlet font color' |
|
46
|
|
|
) |
|
47
|
|
|
->addOption( |
|
48
|
|
|
'bg-color', |
|
49
|
|
|
'b', |
|
50
|
|
|
InputOption::VALUE_OPTIONAL, |
|
51
|
|
|
'Figlet background color' |
|
52
|
|
|
) |
|
53
|
|
|
->addOption( |
|
54
|
|
|
'stretching', |
|
55
|
|
|
's', |
|
56
|
|
|
InputOption::VALUE_OPTIONAL, |
|
57
|
|
|
'Add spaces between characters' |
|
58
|
|
|
) |
|
59
|
|
|
; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @inheritdoc |
|
64
|
|
|
*/ |
|
65
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
66
|
|
|
{ |
|
67
|
|
|
|
|
68
|
|
|
$figlet = new Figlet(); |
|
69
|
|
|
$figlet |
|
70
|
|
|
->setFont($input->getOption('font')); |
|
71
|
|
|
|
|
72
|
|
|
if(null !== $input->getOption('color')){ |
|
73
|
|
|
$figlet->setFontColor($input->getOption('color')); |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
if(null !== $input->getOption('bg-color')){ |
|
77
|
|
|
$figlet->setBackgroundColor($input->getOption('bg-color')); |
|
78
|
|
|
} |
|
79
|
|
|
|
|
80
|
|
|
if(null !== $input->getOption('stretching')){ |
|
81
|
|
|
$figlet->setFontStretching($input->getOption('stretching')); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
$output->write($figlet->render($input->getArgument('text'))); |
|
85
|
|
|
|
|
86
|
|
|
return 0; |
|
87
|
|
|
} |
|
88
|
|
|
} |
|
89
|
|
|
|