Completed
Push — master ( 2dc9c5...1f3c35 )
by Robbie
9s
created

GetCommand::execute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 2
1
<?php
2
3
namespace SilverLeague\Console\Command\Config;
4
5
use SilverLeague\Console\Command\Config\AbstractConfigCommand;
6
use Symfony\Component\Console\Input\InputInterface;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Output\OutputInterface;
9
10
/**
11
 * Lookup configuration settings by class and property name
12
 *
13
 * @package silverstripe-console
14
 * @author  Robbie Averill <[email protected]>
15
 */
16
class GetCommand extends AbstractConfigCommand
17
{
18
    /**
19
     * {@inheritDoc}
20
     */
21
    protected function configure()
22
    {
23
        $this
24
            ->setName('config:get')
25
            ->setDescription('Look up a specific configuration value')
26
            ->addArgument('class', InputArgument::REQUIRED)
27
            ->addArgument('property', InputArgument::REQUIRED);
28
29
        $this->setHelp(<<<HELP
30
Look up a specific configuration value and output it directly. This command can be used for build processes,
31
automated scripts, quick checks etc where raw output is required outside of the SilverStripe application.
32
HELP
33
        );
34
    }
35
36
    /**
37
     * {@inheritDoc}
38
     * @param InputInterface $input
39
     * @param OutputInterface $output
40
     */
41
    protected function execute(InputInterface $input, OutputInterface $output)
42
    {
43
        $result = $this->getConfig()->get(
44
            $input->getArgument('class'),
45
            $input->getArgument('property')
46
        );
47
        $output->writeln(var_export($result, true));
48
    }
49
}
50