Completed
Push — master ( 390e4e...b0ec12 )
by Taosikai
12:57
created

SpikeCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
/**
3
 * Spike library
4
 * @author Tao <[email protected]>
5
 */
6
namespace Spike\Client\Command;
7
8
use Symfony\Component\Console\Helper\DescriptorHelper;
9
use Symfony\Component\Console\Input\InputArgument;
10
use Symfony\Component\Console\Input\InputDefinition;
11
use Symfony\Component\Console\Input\InputOption;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
15
class SpikeCommand extends Command
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    protected function configure()
21
    {
22
        $this->ignoreValidationErrors();
23
        $this->setName('spike')
24
            ->setDefinition($this->createDefinition())
25
            ->setDescription('Spike is a reverse proxy that help to expose your local server to the internet.');
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    protected function execute(InputInterface $input, OutputInterface $output)
32
    {
33
        $helper = new DescriptorHelper();
34
        $helper->describe($output, $this, array(
35
            'format' => $input->getOption('format'),
36
            'raw_text' => $input->getOption('raw'),
37
        ));
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function getNativeDefinition()
44
    {
45
        return $this->createDefinition();
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51
    private function createDefinition()
52
    {
53
        return new InputDefinition(array(
54
            new InputOption('config', null, InputOption::VALUE_OPTIONAL,
55
                'The configuration file, support json,ini,xml and yaml format'),
56
            new InputOption('format', null, InputOption::VALUE_REQUIRED, 'The output format (txt, xml, json, or md)', 'txt'),
57
            new InputOption('raw', null, InputOption::VALUE_NONE, 'To output raw command help'),
58
        ));
59
    }
60
}