Passed
Push — master ( 78a1e9...1a588d )
by Nils
03:05
created

LogfileRemoveCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
namespace Startwind\Inventorio\Command;
4
5
use Symfony\Component\Console\Command\Command;
6
use Symfony\Component\Console\Input\ArrayInput;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\NullOutput;
10
use Symfony\Component\Console\Output\OutputInterface;
11
12
class LogfileRemoveCommand extends InventorioCommand
13
{
14
    protected static $defaultName = 'logfile:remove';
15
    protected static $defaultDescription = 'Remove a logfile to the remote console';
16
17
    /**
18
     * @inheritDoc
19
     */
20
    protected function configure(): void
21
    {
22
        parent::configure();
23
24
        $this
25
            ->addArgument('file', InputArgument::REQUIRED, 'The logfile (absolute path)');
26
    }
27
28
    protected function execute(InputInterface $input, OutputInterface $output): int
29
    {
30
        $this->initConfiguration($input->getOption('configFile'));
31
32
        $file = $input->getArgument('file');
33
34
        $this->config->removeLogfile($file);
35
36
        $output->writeln('- Logfile successfully removed');
37
        $output->writeln('- Running the collect command to sync with inventorio.cloud');
38
39
        $this->getApplication()->find('collect')->run(new ArrayInput([]), new NullOutput());
40
41
        return Command::SUCCESS;
42
    }
43
}
44