Lines Matching refs:this

9  * commands and even generates a help text from this setup.
46 $this->colors = $colors;
48 $this->colors = new Colors();
51 $this->setup = array(
60 $this->args = $this->readPHPArgv();
61 $this->bin = basename(array_shift($this->args));
63 $this->options = array();
71 return $this->bin;
81 $this->setup['']['help'] = $help;
91 $this->setup['']['commandhelp'] = $help;
101 $this->newline = $set ? '' : "\n";
111 * @param bool $required is this a required argument
117 if (!isset($this->setup[$command])) {
121 $this->setup[$command]['args'][] = array(
139 if (isset($this->setup[$command])) {
143 $this->setup[$command] = array(
155 * @param string $help help text for this option
157 * @param bool|string $needsarg does this option require an argument? give it a name here
158 * @param string $command what command does this option apply to
163 if (!isset($this->setup[$command])) {
167 $this->setup[$command]['opts'][$long] = array(
178 $this->setup[$command]['short'][$short] = $long;
193 $argc = count($this->args);
196 foreach ($this->setup[$this->command]['args'] as $arg) {
225 $argc = count($this->args);
227 $arg = $this->args[$i];
232 $non_opts = array_merge($non_opts, array_slice($this->args, $i + 1));
238 $non_opts = array_merge($non_opts, array_slice($this->args, $i));
244 $non_opts = array_merge($non_opts, array_slice($this->args, $i));
254 if (!isset($this->setup[$this->command]['opts'][$opt])) {
259 if ($this->setup[$this->command]['opts'][$opt]['needsarg']) {
260 if (is_null($val) && $i + 1 < $argc && !preg_match('/^--?[\w]/', $this->args[$i + 1])) {
261 $val = $this->args[++$i];
267 $this->options[$opt] = $val;
269 $this->options[$opt] = true;
277 if (!isset($this->setup[$this->command]['short'][$opt])) {
280 $opt = $this->setup[$this->command]['short'][$opt]; // store it under long name
284 if ($this->setup[$this->command]['opts'][$opt]['needsarg']) {
286 if ($i + 1 < $argc && !preg_match('/^--?[\w]/', $this->args[$i + 1])) {
287 $val = $this->args[++$i];
293 $this->options[$opt] = $val;
295 $this->options[$opt] = true;
300 $this->args = $non_opts;
303 if (!$this->command && $this->args && isset($this->setup[$this->args[0]])) {
305 $this->command = array_shift($this->args);
306 $this->parseOptions(); // second pass
325 return $this->options;
328 if (isset($this->options[$option])) {
329 return $this->options[$option];
341 return $this->command;
353 return $this->args;
365 $tf = new TableFormatter($this->colors);
368 $hascommands = (count($this->setup) > 1);
369 $commandhelp = $this->setup['']["commandhelp"];
371 foreach ($this->setup as $command => $config) {
372 $hasopts = (bool)$this->setup[$command]['opts'];
373 $hasargs = (bool)$this->setup[$command]['args'];
377 $text .= $this->colors->wrap('USAGE:', Colors::C_BROWN);
379 $text .= ' ' . $this->bin;
382 $text .= $this->newline;
383 $text .= $this->colors->wrap(' ' . $command, Colors::C_PURPLE);
388 $text .= ' ' . $this->colors->wrap('<OPTIONS>', Colors::C_GREEN);
392 $text .= ' ' . $this->colors->wrap('<COMMAND> ...', Colors::C_PURPLE);
395 foreach ($this->setup[$command]['args'] as $arg) {
396 $out = $this->colors->wrap('<' . $arg['name'] . '>', Colors::C_CYAN);
403 $text .= $this->newline;
406 if ($this->setup[$command]['help']) {
410 array('', $this->setup[$command]['help'] . $this->newline)
418 $text .= $this->colors->wrap('OPTIONS:', Colors::C_BROWN);
421 foreach ($this->setup[$command]['opts'] as $long => $opt) {
441 $text .= $this->newline;
449 $text .= $this->colors->wrap('ARGUMENTS:', Colors::C_BROWN);
451 $text .= $this->newline;
452 foreach ($this->setup[$command]['args'] as $arg) {
466 $text .= $this->colors->wrap('COMMANDS:', Colors::C_BROWN);
472 $text .= $this->newline;