GetCommand::execute()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

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