parse() public méthode

public parse ( array $args = NULL )
$args array
    /** @return CommandLine */
    private function loadOptions()
    {
        $cmd = new CommandLine(<<<XX
Name:
    DB Entities Generator

Description:
    Generate database entities for use with Nette Database.

Usage: 
    index.php [options]

Options:
    -s <path>             SQL file with schema to be parsed to entities.
    -n <namespace>        What namespace to put generated entities into. 
                          Will be used also as destination directory.
                            (default: DbEntity)
    -d <database name>    Used as part of namespace and directory for entities.
                            [optional] (default: none)
    -a                    Generate also absolute constants. This will generate: 
                            const __COLUMN_NAME = 'table.column_name';
                          Constant name is prefixed with (__) two underscores.
                            [optional] (default: true)
    -e                    Enquote table and column names. This will generate: 
                            const __COLUMN_NAME = '`table`.`column_name`';
                            [optional] (default: false)
    -f                    Remove destination directory if exists - use force.
                            [optional] (default: true)
    -h | --help           This help.

XX
, array('-s' => array(CommandLine::REALPATH => TRUE), '-n' => array(CommandLine::VALUE => 'DbEntity'), '-d' => array(CommandLine::OPTIONAL => TRUE, CommandLine::VALUE => ''), '-a' => array(CommandLine::OPTIONAL => TRUE, CommandLine::VALUE => TRUE), '-e' => array(CommandLine::OPTIONAL => TRUE, CommandLine::VALUE => FALSE), '-f' => array(CommandLine::OPTIONAL => TRUE, CommandLine::VALUE => TRUE)));
        $this->options = $cmd->parse();
        return $cmd;
    }
Exemple #2
0
    /** @return CommandLine */
    private function loadOptions()
    {
        echo <<<'XX'
 _____ ___  ___ _____ ___  ___
|_   _/ __)( __/_   _/ __)| _ )
  |_| \___ /___) |_| \___ |_|_\  v1.3.2


XX;
        $cmd = new CommandLine(<<<XX
Usage:
    tester.php [options] [<test file> | <directory>]...

Options:
    -p <path>              Specify PHP interpreter to run (default: php-cgi).
    -c <path>              Look for php.ini file (or look in directory) <path>.
    -l | --log <path>      Write log to file <path>.
    -d <key=value>...      Define INI entry 'key' with value 'val'.
    -s                     Show information about skipped tests.
    --stop-on-fail         Stop execution upon the first failure.
    -j <num>               Run <num> jobs in parallel (default: 8).
    -o <console|tap|none>  Specify output format.
    -w | --watch <path>    Watch directory.
    -i | --info            Show tests environment info and exit.
    --setup <path>         Script for runner setup.
    --colors [1|0]         Enable or disable colors.
    --coverage <path>      Generate code coverage report to file.
    --coverage-src <path>  Path to source code.
    -h | --help            This help.

XX
, array('-c' => array(CommandLine::REALPATH => TRUE), '--watch' => array(CommandLine::REPEATABLE => TRUE, CommandLine::REALPATH => TRUE), '--setup' => array(CommandLine::REALPATH => TRUE), 'paths' => array(CommandLine::REPEATABLE => TRUE, CommandLine::VALUE => getcwd()), '--debug' => array(), '--coverage-src' => array(CommandLine::REALPATH => TRUE)));
        if (isset($_SERVER['argv'])) {
            if ($tmp = array_search('-log', $_SERVER['argv'])) {
                $_SERVER['argv'][$tmp] = '--log';
            }
            if ($tmp = array_search('--tap', $_SERVER['argv'])) {
                unset($_SERVER['argv'][$tmp]);
                $_SERVER['argv'] = array_merge($_SERVER['argv'], array('-o', 'tap'));
            }
        }
        $this->options = $cmd->parse();
        return $cmd;
    }
Exemple #3
0
    --tap                  Generate Test Anything Protocol.
    -j <num>               Run <num> jobs in parallel (default: 33).
    -w | --watch <path>    Watch directory.
    -i | --info            Show tests environment info and exit.
    --setup <path>         Script for runner setup.
    --colors [1|0]         Enable or disable colors.
    --coverage <path>      Generate code coverage report to file.
    --coverage-src <path>  Path to source code.
    -h | --help            This help.

XX
, array('-c' => array(Cmd::REALPATH => TRUE), '--watch' => array(Cmd::REPEATABLE => TRUE, Cmd::REALPATH => TRUE), '--setup' => array(Cmd::REALPATH => TRUE), 'paths' => array(Cmd::REPEATABLE => TRUE, Cmd::VALUE => getcwd()), '--debug' => array(), '--coverage-src' => array(Cmd::REALPATH => TRUE)));
if (isset($_SERVER['argv']) && ($tmp = array_search('-log', $_SERVER['argv']))) {
    $_SERVER['argv'][$tmp] = '--log';
}
$options = $cmd->parse();
Tester\Environment::$debugMode = (bool) $options['--debug'];
if (isset($options['--colors'])) {
    Tester\Environment::$useColors = (bool) $options['--colors'];
} elseif ($options['--tap']) {
    Tester\Environment::$useColors = FALSE;
}
if ($cmd->isEmpty() || $options['--help']) {
    $cmd->help();
    exit;
}
$phpArgs = '';
if ($options['-c']) {
    $phpArgs .= ' -c ' . Tester\Helpers::escapeArg($options['-c']);
} elseif (!$options['--info']) {
    echo "Note: No php.ini is used.\n";