12
12
13
13
namespace cli ;
14
14
15
- require 'lib/cli/Memoize.php ' ;
16
- require 'lib/cli/arguments/Argument.php ' ;
17
- require 'lib/cli/arguments/HelpScreen.php ' ;
18
- require 'lib/cli/arguments/InvalidArguments.php ' ;
19
- require 'lib/cli/arguments/Lexer.php ' ;
20
-
21
15
/**
22
16
* Parses command line arguments.
23
17
*/
@@ -69,7 +63,7 @@ public function getArguments() {
69
63
}
70
64
71
65
public function getHelpScreen () {
72
- return new \ cli \ arguments \HelpScreen ($ this );
66
+ return new arguments \HelpScreen ($ this );
73
67
}
74
68
75
69
/**
@@ -88,7 +82,7 @@ public function asJSON() {
88
82
* @return bool
89
83
*/
90
84
public function offsetExists ($ offset ) {
91
- if ($ offset instanceOf \ cli \ arguments \Argument) {
85
+ if ($ offset instanceOf arguments \Argument) {
92
86
$ offset = $ offset ->key ;
93
87
}
94
88
@@ -102,7 +96,7 @@ public function offsetExists($offset) {
102
96
* @return mixed
103
97
*/
104
98
public function offsetGet ($ offset ) {
105
- if ($ offset instanceOf \ cli \ arguments \Argument) {
99
+ if ($ offset instanceOf arguments \Argument) {
106
100
$ offset = $ offset ->key ;
107
101
}
108
102
@@ -118,7 +112,7 @@ public function offsetGet($offset) {
118
112
* @param mixed $value The value to set
119
113
*/
120
114
public function offsetSet ($ offset , $ value ) {
121
- if ($ offset instanceOf \ cli \ arguments \Argument) {
115
+ if ($ offset instanceOf arguments \Argument) {
122
116
$ offset = $ offset ->key ;
123
117
}
124
118
@@ -131,7 +125,7 @@ public function offsetSet($offset, $value) {
131
125
* @param mixed $offset An Argument object or the name of the argument.
132
126
*/
133
127
public function offsetUnset ($ offset ) {
134
- if ($ offset instanceOf \ cli \ arguments \Argument) {
128
+ if ($ offset instanceOf arguments \Argument) {
135
129
$ offset = $ offset ->key ;
136
130
}
137
131
@@ -197,7 +191,7 @@ public function addFlags($flags) {
197
191
/**
198
192
* Adds an option (string argument) to the argument list.
199
193
*
200
- * @param mixed $flag A string representing the option, or an array of strings.
194
+ * @param mixed $option A string representing the option, or an array of strings.
201
195
* @param array $settings An array of settings for this option.
202
196
* @setting string description A description to be shown in --help.
203
197
* @setting bool default The default value for this option.
@@ -341,7 +335,7 @@ public function isStackable($flag) {
341
335
* @return array
342
336
*/
343
337
public function getOption ($ option ) {
344
- if ($ option instanceOf \ cli \ arguments \Argument) {
338
+ if ($ option instanceOf arguments \Argument) {
345
339
$ obj = $ option ;
346
340
$ option = $ option ->value ;
347
341
}
@@ -386,11 +380,12 @@ public function isOption($argument) {
386
380
* if a long name is not given.
387
381
*
388
382
* @return array
383
+ * @throws arguments\InvalidArguments
389
384
*/
390
385
public function parse () {
391
386
$ this ->_invalid = array ();
392
387
$ this ->_parsed = array ();
393
- $ this ->_lexer = new \ cli \ arguments \Lexer ($ this ->_input );
388
+ $ this ->_lexer = new arguments \Lexer ($ this ->_input );
394
389
395
390
foreach ($ this ->_lexer as $ argument ) {
396
391
if ($ this ->_parseFlag ($ argument )) {
@@ -404,7 +399,7 @@ public function parse() {
404
399
}
405
400
406
401
if ($ this ->_strict && !empty ($ this ->_invalid )) {
407
- throw new \ cli \ arguments \InvalidArguments ($ this ->_invalid );
402
+ throw new arguments \InvalidArguments ($ this ->_invalid );
408
403
}
409
404
}
410
405
0 commit comments