1
|
|
|
<?php |
2
|
|
|
namespace Peridot\Console; |
3
|
|
|
|
4
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
5
|
|
|
use Symfony\Component\Console\Input\InputDefinition as Definition; |
6
|
|
|
use Symfony\Component\Console\Input\InputOption; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* The InputDefinition for Peridot defines what command line arguments |
10
|
|
|
* and options are available by default. |
11
|
|
|
* |
12
|
|
|
* @package Peridot\Console |
13
|
|
|
*/ |
14
|
|
|
class InputDefinition extends Definition |
15
|
|
|
{ |
16
|
|
|
/** |
17
|
|
|
* Define input definition for peridot |
18
|
|
|
*/ |
19
|
|
|
public function __construct() |
20
|
|
|
{ |
21
|
|
|
parent::__construct([]); |
22
|
|
|
$this->addArgument(new InputArgument('path', InputArgument::OPTIONAL | InputArgument::IS_ARRAY, 'The path to a directory or file containing specs', ['spec', 'specs', 'test', 'tests'])); |
23
|
|
|
|
24
|
|
|
$this->addOption(new InputOption('focus', 'f', InputOption::VALUE_REQUIRED, 'Run tests matching <pattern>')); |
25
|
|
|
$this->addOption(new InputOption('skip', 's', InputOption::VALUE_REQUIRED, 'Skip tests matching <pattern>')); |
26
|
|
|
$this->addOption(new InputOption('grep', 'g', InputOption::VALUE_REQUIRED, 'Run tests with filenames matching <pattern> <comment>(default: *.spec.php)</comment>')); |
27
|
|
|
$this->addOption(new InputOption('no-colors', 'C', InputOption::VALUE_NONE, 'Disable output colors')); |
28
|
|
|
$this->addOption(new InputOption('--force-colors', null, InputOption::VALUE_NONE, 'Force output colors')); |
29
|
|
|
$this->addOption(new InputOption('reporter', 'r', InputOption::VALUE_REQUIRED, 'Select which reporter to use <comment>(default: spec)</comment>')); |
30
|
|
|
$this->addOption(new InputOption('bail', 'b', InputOption::VALUE_NONE, 'Stop on failure')); |
31
|
|
|
$this->addOption(new InputOption('configuration', 'c', InputOption::VALUE_REQUIRED, 'A php file containing peridot configuration')); |
32
|
|
|
$this->addOption(new InputOption('reporters', null, InputOption::VALUE_NONE, 'List all available reporters')); |
33
|
|
|
$this->addOption(new InputOption('--version', '-V', InputOption::VALUE_NONE, 'Display the Peridot version number')); |
34
|
|
|
$this->addOption(new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message.')); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Add an option |
39
|
|
|
* |
40
|
|
|
* @param string $name |
41
|
|
|
* @param null $shortcut |
42
|
|
|
* @param null $mode |
43
|
|
|
* @param string $description |
44
|
|
|
* @param null $default |
45
|
|
|
* @return InputDefinition |
46
|
|
|
*/ |
47
|
|
|
public function option($name, $shortcut = null, $mode = null, $description = '', $default = null) |
48
|
|
|
{ |
49
|
|
|
$option = new InputOption($name, $shortcut, $mode, $description, $default); |
50
|
|
|
$this->addOption($option); |
51
|
|
|
|
52
|
|
|
return $this; |
53
|
|
|
} |
54
|
|
|
} |
55
|
|
|
|