1
|
|
|
<?php |
2
|
|
|
namespace Consolidation\AnnotatedCommand; |
3
|
|
|
|
4
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
5
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
6
|
|
|
|
7
|
|
|
class CommandData |
8
|
|
|
{ |
9
|
|
|
/** var AnnotationData */ |
10
|
|
|
protected $annotationData; |
11
|
|
|
/** var InputInterface */ |
12
|
|
|
protected $input; |
13
|
|
|
/** var OutputInterface */ |
14
|
|
|
protected $output; |
15
|
|
|
/** var boolean */ |
16
|
|
|
protected $usesInputInterface; |
17
|
|
|
/** var boolean */ |
18
|
|
|
protected $usesOutputInterface; |
19
|
|
|
|
20
|
|
|
public function __construct( |
21
|
|
|
AnnotationData $annotationData, |
22
|
|
|
InputInterface $input, |
23
|
|
|
OutputInterface $output, |
24
|
|
|
$usesInputInterface, |
25
|
|
|
$usesOutputInterface |
26
|
|
|
) { |
27
|
|
|
$this->annotationData = $annotationData; |
28
|
|
|
$this->input = $input; |
29
|
|
|
$this->output = $output; |
30
|
|
|
$this->usesInputInterface = $usesInputInterface; |
31
|
|
|
$this->usesOutputInterface = $usesOutputInterface; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
public function annotationData() |
35
|
|
|
{ |
36
|
|
|
return $this->annotationData; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function input() |
40
|
|
|
{ |
41
|
|
|
return $this->input; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function output() |
45
|
|
|
{ |
46
|
|
|
return $this->output; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function arguments() |
50
|
|
|
{ |
51
|
|
|
return $this->input->getArguments(); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function options() |
55
|
|
|
{ |
56
|
|
|
return $this->input->getOptions(); |
57
|
|
|
} |
58
|
|
|
|
59
|
|
|
public function getArgsWithoutAppName() |
60
|
|
|
{ |
61
|
|
|
$args = $this->arguments(); |
62
|
|
|
|
63
|
|
|
// When called via the Application, the first argument |
64
|
|
|
// will be the command name. The Application alters the |
65
|
|
|
// input definition to match, adding a 'command' argument |
66
|
|
|
// to the beginning. |
67
|
|
|
array_shift($args); |
68
|
|
|
return $args; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
public function getArgsAndOptions() |
72
|
|
|
{ |
73
|
|
|
// Get passthrough args, and add the options on the end. |
74
|
|
|
$args = $this->getArgsWithoutAppName(); |
75
|
|
|
$args['options'] = $this->options(); |
76
|
|
|
return $args; |
77
|
|
|
} |
78
|
|
|
} |
79
|
|
|
|