Handles the "ls" command.

@param Args $args The console arguments.
@param IO   $io   The I/O.

@return int The status code.
555721
public function handle(Args $args, IO $io)
    {
        $path = Path::makeAbsolute($args->getArgument('path'), $this->currentPath);

        $resource = $this->repo->get($path);

        if (!$resource->hasChildren()) {
            throw new RuntimeException(sprintf(
                'The resource "%s" does not have children.',
                $resource->getPath()
            ));
        }

        if ($args->isOptionSet('long')) {
            $this->listLong($io, $resource->listChildren());

            return 0;
        }

        $this->listShort($io, $resource->listChildren());

        return 0;
    }
1026245
public function callHandler(array $command, $method, $args = array())
    {
        try {
            $handlers = $this->getHandlers();
            return Handler::call($handlers, $command['command_id'], $method, $args);
        } catch (Exception $ex) {
            return $ex->getMessage();
        }
    }
435287
public function execute(Arguments $args, ConsoleIo $io)
    {
        $io->out(Configure::version());

        return static::CODE_SUCCESS;
    }
1043682
protected function displayHelp(ConsoleOptionParser $parser, Arguments $args, ConsoleIo $io)
    {
        $format = 'text';
        if ($args->getArgumentAt(0) === 'xml') {
            $format = 'xml';
            $io->setOutputAs(ConsoleOutput::RAW);
        }

        $io->out($parser->help(null, $format));
    }
155357
public final void parseCLI(final String[] args) throws IOException,
      JDOMException {
    try {
      this.parsedArguments = this.argParser.parseArgs(args);
      System.err.println("CLI options: " + this.parsedArguments);
      if (args[0].equals("parse")) {
        annotate(System.in, System.out);
      } else if (args[0].equals("eval")) {
        eval();
      } else if (args[0].equals("train")) {
        train();
      } else if (args[0].equals("server")) {
        server();
      } else if (args[0].equals("client")) {
        client(System.in, System.out);
      }
    } catch (final ArgumentParserException e) {
      this.argParser.handleError(e);
      System.out.println("Run java -jar target/ixa-pipe-parse-" + this.version
          + ".jar" + " (parse|train|eval|server|client) -help for details");
      System.exit(1);
    }
  }
433379
function handleswitch($i, $argv)
    {
        $lv = 0;
        $dv = 0.0;
        $sv = $end = $cp = '';
        $j; // int
        $errcnt = 0;
        $cp = strstr($argv[$i], '=');
        if (!$cp) {
            throw new Exception('INTERNAL ERROR: handleswitch passed bad argument, no "=" in arg');
        }
        $argv[$i] = substr($argv[$i], 0, strlen($argv[$i]) - strlen($cp));
        if (!isset(self::$_options[$argv[$i]])) {
            throw new Exception('Command line syntax error: undefined option "' .  $argv[$i] .
                $cp . '"');
        }
        $cp = substr($cp, 1);
        switch (self::$_options[$argv[$i]]['type']) {
        case self::OPT_FLAG:
        case self::OPT_FFLAG:
            throw new Exception('Command line syntax error: option requires an argument "' .
                $argv[$i] . '=' . $cp . '"');
        case self::OPT_DBL:
        case self::OPT_FDBL:
            $dv = (double) $cp;
            break;
        case self::OPT_INT:
        case self::OPT_FINT:
            $lv = (int) $cp;
            break;
        case self::OPT_STR:
        case self::OPT_FSTR:
            $sv = $cp;
            break;
        }
        switch(self::$_options[$argv[$i]]['type']) {
        case self::OPT_FLAG:
        case self::OPT_FFLAG:
            break;
        case self::OPT_DBL:
            $this->{self::$_options[$argv[$i]]['arg']} = $dv;
            break;
        case self::OPT_FDBL:
            $this->{self::$_options[$argv[$i]]['arg']}($dv);
            break;
        case self::OPT_INT:
            $this->{self::$_options[$argv[$i]]['arg']} = $lv;
            break;
        case self::OPT_FINT:
            $this->{self::$_options[$argv[$i]]['arg']}($lv);
            break;
        case self::OPT_STR:
            $this->{self::$_options[$argv[$i]]['arg']} = $sv;
            break;
        case self::OPT_FSTR:
            $this->{self::$_options[$argv[$i]]['arg']}($sv);
            break;
        }
        return 0;
    }
751389
protected function executeCommand($args)
    {
        $io = clone $this->io;

        $io->setArguments($args);
        $io->setOption('no-backup', true);
        $io->setOption('no-create-database', true);

//        foreach ($this->io->getOptions() as $k => $v)
//        {
//            $io->setOption($k, $v);
//        }

        return $this->console->getRootCommand()->setIO($io)->execute();
    }
404376
public function execute(Arguments $args, ConsoleIo $io)
    {
        foreach (Configure::read('WRITABLE_DIRS') as $path) {
            $this->folderChmod($io, $path);
        }

        return null;
    }
593691
public function start_lvl(&$output, $depth = 0, $args = [])
    {
        $GLOBALS['comment_depth'] = $depth + 1;

        switch ($args['style']) {
            case 'div':
                break;
            case 'ol':
                $output .= '<ol class="children list-unstyled">'.PHP_EOL;
                break;
            case 'ul':
            default:
                $output .= '<ul class="children list-unstyled">'.PHP_EOL;
                break;
        }
    }
744509
public function execute(Arguments $args, ConsoleIo $io)
    {
        try {
            //Will trigger events provided by `LinkScannerCommandEventListener`
            $this->LinkScanner->getEventManager()->on(new LinkScannerCommandEventListener($args, $io));

            if ($args->getOption('follow-redirects')) {
                $this->LinkScanner->setConfig('followRedirects', true);
            }
            if ($args->getOption('force')) {
                $this->LinkScanner->setConfig('lockFile', false);
            }
            if ($args->hasOption('full-base-url')) {
                $this->LinkScanner->setConfig('fullBaseUrl', $args->getOption('full-base-url'));
            }
            if ($args->hasOption('max-depth')) {
                $this->LinkScanner->setConfig('maxDepth', $args->getOption('max-depth'));
            }
            if ($args->getOption('no-cache')) {
                $this->LinkScanner->setConfig('cache', false);
            }
            if ($args->getOption('no-external-links')) {
                $this->LinkScanner->setConfig('externalLinks', false);
            }
            if ($args->hasOption('timeout')) {
                $this->LinkScanner->Client->setConfig('timeout', $args->getOption('timeout'));
            }

            $this->LinkScanner->scan();

            if ($args->getOption('export-with-filename') || $args->getOption('export')) {
                $this->LinkScanner->export($args->getOption('export-with-filename'));
            }
        } catch (Exception $e) {
            $io->error($e->getMessage());
            $this->abort();
        }

        return null;
    }
328945
public function handle($event, $args) {
		if (isset($this->callback[$event])) {
			$this->callback[$event](...$args);
		}
	}
999581
public function executeHello(array $args, array $options = array())
    {
        $name = 'unknown';
        if (empty($args)) {
            $dialog = new Dialog($this->console);
            $name = $dialog->ask('What is your name?', $name);
        } else {
            $name = $args[0];
        }
        $this->writeln(sprintf('hello %s!', $name));
    }
1179868
public static function run($args, $extra = [])
    {
        static::$_out = '';
        $argv = explode(' ', "dummy-shell.php {$args}");
        $dispatcher = new WebShellDispatcher($argv);

        ob_start();
        $response = $dispatcher->dispatch($extra);
        static::$_out = ob_get_clean();

        return (int)($response === 0);
    }
709827
public function executeByPath($arguments, array $options = [], IOInterface $io = null)
    {
        $io = $io ?: clone $this->io;

        // Path
        if (is_string($arguments)) {
            $arguments = str_replace('/', ' ', $arguments);
            $arguments = array_filter(explode(' ', $arguments), 'strlen');
        }

        $io->setArguments($arguments);

        // Options
        foreach ($options as $key => $value) {
            $io->setOption($key, $value);
        }

        return $this->getRootCommand()->setIO($io)->execute();
    }
1253591
public function handleList(Args $args, IO $io)
    {
        $moduleNames = ArgsUtil::getModuleNames($args, $this->modules);
        $states = $this->getPathMappingStates($args);

        $printState = count($states) > 1;
        $printModuleName = count($moduleNames) > 1;
        $printHeaders = $printState || $printModuleName;
        $printAdvice = true;
        $indentation = ($printState && $printModuleName) ? 8
            : ($printState || $printModuleName ? 4 : 0);

        foreach ($states as $state) {
            $statePrinted = !$printState;

            if (PathMappingState::CONFLICT === $state) {
                $expr = Expr::method('getContainingModule', Expr::method('getName', Expr::in($moduleNames)))
                    ->andMethod('getState', Expr::same($state));

                $mappings = $this->repoManager->findPathMappings($expr);

                if (!$mappings) {
                    continue;
                }

                $printAdvice = false;

                if ($printState) {
                    $this->printPathMappingStateHeader($io, $state);
                }

                $this->printConflictTable($io, $mappings, $printState ? 4 : 0);

                if ($printHeaders) {
                    $io->writeLine('');
                }

                continue;
            }

            foreach ($moduleNames as $moduleName) {
                $expr = Expr::method('getContainingModule', Expr::method('getName', Expr::same($moduleName)))
                    ->andMethod('getState', Expr::same($state));

                $mappings = $this->repoManager->findPathMappings($expr);

                if (!$mappings) {
                    continue;
                }

                $printAdvice = false;

                if (!$statePrinted) {
                    $this->printPathMappingStateHeader($io, $state);
                    $statePrinted = true;
                }

                if ($printModuleName) {
                    $prefix = $printState ? '    ' : '';
                    $io->writeLine(sprintf('%sModule: %s', $prefix, $moduleName));
                    $io->writeLine('');
                }

                $this->printMappingTable($io, $mappings, $indentation, PathMappingState::ENABLED === $state);

                if ($printHeaders) {
                    $io->writeLine('');
                }
            }
        }

        if ($printAdvice) {
            $io->writeLine('No path mappings. Use "puli map <path> <file>" to map a Puli path to a file or directory.');
        }

        return 0;
    }
714700
public function handle(array $args = [])
    {
        // remove source file name from argv
        $source = array_shift($args);

        /** @var ConsoleEvent $applicationEvent */
        $applicationEvent = $this->getApplicationEvent();
        $applicationEvent->setName(self::EVENT_REQUEST_RECEIVED);
        $applicationEvent->setSourceFile($source);
        $applicationEvent->setArguments($args);
        $this->emit($applicationEvent);

        // init dispatcher
        $dispatcher = new Dispatcher($this->commands, $this->container);

        $middlewareRunner = new MiddlewareRunner($this->getMiddlewares());

        $middlewareRunner->run([$applicationEvent->getArguments()], function ($args) use ($applicationEvent, $dispatcher) {
            // dispatch command with args from cli
            $dispatcher->dispatch($args);
        });
    }
634350
public function execute(array $args, array $options = [])
    {
        $this->bootstrap($args, $options);

        $format = isset($options['format']) ? $options['format'] : $options['f'];

        if (null !== $format) {
            Output::writeln('using format ' . $format);
        }

        $this->getManager()->printStatus($format);
    }