1 | <?php |
||
22 | class CommandLine implements Command |
||
23 | { |
||
24 | /** |
||
25 | * List of system commands to execute. |
||
26 | * |
||
27 | * @var \SebastianFeldmann\Cli\Command[] |
||
28 | */ |
||
29 | private $commands = []; |
||
30 | |||
31 | /** |
||
32 | * Redirect the output |
||
33 | * |
||
34 | * @var string |
||
35 | */ |
||
36 | private $redirectOutput; |
||
37 | |||
38 | /** |
||
39 | * Output pipeline |
||
40 | * |
||
41 | * @var \SebastianFeldmann\Cli\Command[] |
||
42 | */ |
||
43 | private $pipeline = []; |
||
44 | |||
45 | /** |
||
46 | * List of acceptable exit codes. |
||
47 | * |
||
48 | * @var array |
||
49 | */ |
||
50 | private $acceptedExitCodes = [0]; |
||
51 | |||
52 | /** |
||
53 | * Set the list of accepted exit codes. |
||
54 | * |
||
55 | * @param int[] $codes |
||
56 | * @return void |
||
57 | */ |
||
58 | 1 | public function acceptExitCodes(array $codes) : void |
|
62 | |||
63 | /** |
||
64 | * Redirect the stdOut. |
||
65 | * |
||
66 | * @param string $path |
||
67 | * @return void |
||
68 | */ |
||
69 | 1 | public function redirectOutputTo($path) : void |
|
73 | |||
74 | /** |
||
75 | * Should the output be redirected. |
||
76 | * |
||
77 | * @return bool |
||
78 | */ |
||
79 | 1 | public function isOutputRedirected() : bool |
|
83 | |||
84 | /** |
||
85 | * Redirect getter. |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | 1 | public function getRedirectPath() : string |
|
93 | |||
94 | /** |
||
95 | * Pipe the command into given command. |
||
96 | * |
||
97 | * @param \SebastianFeldmann\Cli\Command $cmd |
||
98 | * @return void |
||
99 | */ |
||
100 | 1 | public function pipeOutputTo(Command $cmd) : void |
|
107 | |||
108 | /** |
||
109 | * Can the pipe '|' operator be used. |
||
110 | * |
||
111 | * @return bool |
||
112 | */ |
||
113 | 1 | public function canPipe() : bool |
|
117 | |||
118 | /** |
||
119 | * Is there a command pipeline. |
||
120 | * |
||
121 | * @return bool |
||
122 | */ |
||
123 | 3 | public function isPiped() : bool |
|
127 | |||
128 | /** |
||
129 | * Return command pipeline. |
||
130 | * |
||
131 | * @return string |
||
132 | */ |
||
133 | 3 | public function getPipeline() : string |
|
137 | |||
138 | /** |
||
139 | * Adds a cli command to list of commands to execute. |
||
140 | * |
||
141 | * @param \SebastianFeldmann\Cli\Command |
||
142 | * @return void |
||
143 | */ |
||
144 | 4 | public function addCommand(Command $cmd) : void |
|
148 | |||
149 | /** |
||
150 | * Generates the system command. |
||
151 | * |
||
152 | * @return string |
||
153 | */ |
||
154 | 4 | public function getCommand() : string |
|
166 | |||
167 | /** |
||
168 | * Returns a list of exit codes that are valid. |
||
169 | * |
||
170 | * @return array |
||
171 | */ |
||
172 | 1 | public function getAcceptableExitCodes() : array |
|
176 | |||
177 | /** |
||
178 | * Returns the command to execute. |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | 1 | public function __toString() : string |
|
186 | } |
||
187 |