BuildCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 19
ccs 0
cts 19
cp 0
rs 9.4285
cc 1
eloc 14
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * For licensing information, please see the LICENSE file accompanied with this file.
4
 *
5
 * @author Gerard van Helden <[email protected]>
6
 * @copyright 2012 Gerard van Helden <http://melp.nl>
7
 */
8
9
namespace Zicht\Tool\Packager\Cmd;
10
11
use Symfony\Component\Console\Command\Command;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
use Symfony\Component\Console\Input\InputOption;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Zicht\Tool\Packager\Packager;
17
18
/**
19
 * Command for building a package.
20
 */
21
class BuildCommand extends Command
22
{
23
    /**
24
     * @{inheritDoc}
25
     */
26
    protected function configure()
27
    {
28
        parent::configure();
29
        $this
30
            ->setName('build')
31
            ->addArgument('file', InputArgument::OPTIONAL, 'File name to write to', 'z')
32
            ->addOption('force', 'f', InputOption::VALUE_NONE, 'Force the file to be written')
33
            ->addOption('app-version', '', InputOption::VALUE_REQUIRED, 'Version string for the build')
34
            ->addOption('app-name', '', InputOption::VALUE_REQUIRED, 'Name of the application')
35
            ->addOption(
36
                'config-filename', '', InputOption::VALUE_REQUIRED,
37
                'The config file name for the app to use (typically z.yml)'
38
            )
39
            ->addOption(
40
                'static', '', InputOption::VALUE_REQUIRED,
41
                "Create a static build using the specified config file"
42
            )
43
        ;
44
    }
45
46
    /**
47
     * @{inheritDoc}
48
     */
49
    protected function execute(InputInterface $input, OutputInterface $output)
50
    {
51
        $t = microtime(true);
52
        $packager = new Packager(__DIR__ . '/../../../../../', array_filter($input->getOptions()));
53
54
        $result = $packager->package($input->getArgument('file'), $input->getOption('force'));
55
56
        if ($output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL) {
57
            $output->writeln(sprintf("Built {$result} in %.2f seconds", microtime(true) - $t));
58
        }
59
    }
60
}
61