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, 'The path to a directory or file containing specs')); |
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 | InputOption::VALUE_IS_ARRAY, 'Select which reporter(s) to use', ['spec'])); |
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 argument |
39
|
|
|
* |
40
|
|
|
* @param string $name |
41
|
|
|
* @param null $mode |
42
|
|
|
* @param string $description |
43
|
|
|
* @param null $default |
44
|
|
|
* @return InputDefinition |
45
|
|
|
*/ |
46
|
|
|
public function argument($name, $mode = null, $description = '', $default = null) |
47
|
|
|
{ |
48
|
|
|
$argument = new InputArgument($name, $mode, $description, $default); |
49
|
|
|
$this->addArgument($argument); |
50
|
|
|
|
51
|
|
|
return $this; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Add an option |
56
|
|
|
* |
57
|
|
|
* @param string $name |
58
|
|
|
* @param null $shortcut |
59
|
|
|
* @param null $mode |
60
|
|
|
* @param string $description |
61
|
|
|
* @param null $default |
62
|
|
|
* @return InputDefinition |
63
|
|
|
*/ |
64
|
|
|
public function option($name, $shortcut = null, $mode = null, $description = '', $default = null) |
65
|
|
|
{ |
66
|
|
|
$option = new InputOption($name, $shortcut, $mode, $description, $default); |
67
|
|
|
$this->addOption($option); |
68
|
|
|
|
69
|
|
|
return $this; |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|