CompactCommand::configure()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
3
/**
4
 * @file CompactCommand.php
5
 * @brief This file contains the CompactCommand class.
6
 * @details
7
 * @author Filippo F. Fadda
8
 */
9
10
11
namespace EoC\CLI\Command;
12
13
14
use Symfony\Component\Console\Input\InputOption;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Output\OutputInterface;
17
18
19
/**
20
 * @brief Starts a compaction for the current selected database.
21
 * @nosubgrouping
22
 */
23
class CompactCommand extends AbstractCommand {
24
25
26
  /**
27
   * @brief Configures the command.
28
   */
29
  protected function configure() {
30
    $this->setName("compact");
31
    $this->setDescription("Starts a compaction for the current selected database or just a set of views");
32
33
    $this->addOption("design-doc",
34
      NULL,
35
      InputOption::VALUE_REQUIRED,
36
      "Name of the design document where are stored the views to compact");
37
  }
38
39
40
  /**
41
   * @brief Executes the command.
42
   */
43
  protected function execute(InputInterface $input, OutputInterface $output) {
44
    $couch = $this->getConnection();
45
46
    if ($designDoc = $input->getOption('design-doc'))
47
      $couch->compactView($this->getDatabase(), $designDoc);
48
    else
49
      $couch->compactDb($this->getDatabase());
50
  }
51
52
}