当前位置: 首页>>代码示例>>PHP>>正文


PHP Console_CommandLine类代码示例

本文整理汇总了PHP中Console_CommandLine的典型用法代码示例。如果您正苦于以下问题:PHP Console_CommandLine类的具体用法?PHP Console_CommandLine怎么用?PHP Console_CommandLine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Console_CommandLine类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     $this->concentrator = new Concentrate_Concentrator();
     $this->parser = Console_CommandLine::fromXmlFile($this->getUiXml());
     try {
         $result = $this->parser->parse();
         $this->setOptions($result->options);
         $this->setWebRoot($result->args['webroot']);
         $this->loadDataFiles();
         if ($this->combine) {
             $this->writeCombinedFiles();
             $this->writeCombinedFlagFile();
         }
         if ($this->compile) {
             $this->writeCompiledFiles();
             $this->writeCompiledFlagFile();
         }
         if ($this->minify) {
             $this->writeMinifiedFiles();
             $this->writeMinifiedFlagFile();
         }
     } catch (Console_CommandLine_Exception $e) {
         $this->displayError($e->getMessage() . PHP_EOL);
     } catch (Exception $e) {
         $this->displayError($e->getMessage() . PHP_EOL, false);
         $this->displayError($e->getTraceAsString() . PHP_EOL);
     }
 }
开发者ID:GervaisdeM,项目名称:Concentrate,代码行数:28,代码来源:CLI.php

示例2: loadParams

 /**
  * Loads and parses command line parameters.
  * Also takes care of the --help switch.
  *
  * @return void
  *
  * @throws Exception When the rST file does not exist
  */
 protected function loadParams()
 {
     $parser = new \Console_CommandLine();
     $parser->description = 'Deploy reStructuredText documents into a wiki';
     $parser->version = '@version@';
     $parser->addArgument('file', array('description' => 'rST file path'));
     $parser->addOption('driver', array('long_name' => '--driver', 'optional' => true, 'action' => 'StoreString', 'description' => 'Wiki driver to use'));
     //No -D options: https://pear.php.net/bugs/bug.php?id=19163
     //yep, that does not automatically work with new drivers
     Driver_Confluence::loadHelp($parser);
     try {
         $result = $parser->parse();
         foreach (array_keys($result->options) as $key) {
             if ($result->options[$key] === null) {
                 unset($result->options[$key]);
             }
         }
         $this->options = array_merge($this->options, $result->options);
     } catch (\Console_CommandLine_Exception $e) {
         $parser->displayError($e->getMessage());
     }
     $this->file = $result->args['file'];
     if (!file_exists($this->file)) {
         throw new Exception('File does not exist', 2);
     }
 }
开发者ID:netresearch,项目名称:deploy-rst,代码行数:34,代码来源:Cli.php

示例3: add

 /**
  * Class constructor
  *
  * @param \Console_CommandLine  $parser
  * @param \Monolog\logger       $logger
  */
 public function add($command, $parameters)
 {
     if (empty($parameters["class"])) {
         $this->logger->error("Skipping command " . $command . ": invalid command definition", array("NAME" => $command, "PARAMETERS" => $parameters));
         return false;
     }
     // replace double backslashes from classname (if any!)
     $class = str_replace('\\\\', '\\', $parameters["class"]);
     if (!class_exists($class)) {
         $this->logger->error("Skipping command " . $command . ": missing class", array("NAME" => $command, "CLASS" => $class));
         return false;
     }
     $this->command_classes[$command] = $class;
     $params = array();
     if (array_key_exists('description', $parameters)) {
         $params['description'] = $parameters['description'];
     }
     if (array_key_exists('aliases', $parameters) && is_array($parameters['aliases'])) {
         $params['aliases'] = $parameters['aliases'];
     }
     $command = $this->parser->addCommand($command, $params);
     if (array_key_exists('options', $parameters) && is_array($parameters['options'])) {
         foreach ($parameters['options'] as $option => $option_parameters) {
             $command->addOption($option, $option_parameters);
         }
     }
     if (array_key_exists('arguments', $parameters) && is_array($parameters['arguments'])) {
         foreach ($parameters['arguments'] as $argument => $argument_parameters) {
             $command->addArgument($argument, $argument_parameters);
         }
     }
     return true;
 }
开发者ID:comodojo,项目名称:extender.framework,代码行数:39,代码来源:Controller.php

示例4: validate

 /**
  * Validates the argument instance.
  *
  * @return void
  * @throws Console_CommandLine_Exception
  * @todo use exceptions
  */
 public function validate()
 {
     // check if the argument name is valid
     if (!preg_match('/^[a-zA-Z_\\x7f-\\xff]+[a-zA-Z0-9_\\x7f-\\xff]*$/', $this->name)) {
         Console_CommandLine::triggerError('argument_bad_name', E_USER_ERROR, array('{$name}' => $this->name));
     }
     parent::validate();
 }
开发者ID:ntemple,项目名称:intelli-plancake,代码行数:15,代码来源:Argument.php

示例5: loadHelp

 /**
  * Loads confluence-specific options into the command line parser
  *
  * @param object $parser Command line parser object
  *
  * @return void
  */
 public static function loadHelp(\Console_CommandLine $parser)
 {
     $parser->addOption('user', array('long_name' => '--user', 'optional' => true, 'action' => 'StoreString', 'description' => 'Confluence user name'));
     $parser->addOption('password', array('long_name' => '--password', 'optional' => true, 'action' => 'StoreString', 'description' => 'Confluence user password'));
     $parser->addOption('no_deploy', array('long_name' => '--no-deploy', 'optional' => true, 'action' => 'StoreTrue', 'description' => 'Do not deploy, echo output only'));
     $parser->addOption('filter', array('long_name' => '--filter', 'optional' => true, 'action' => 'StoreString', 'description' => 'rST filter name (e.g. "aida")'));
     $parser->addOption('confluence_host', array('long_name' => '--confluence-host', 'optional' => true, 'action' => 'StoreString', 'description' => 'Confluence host name (with http://)', 'help_name' => 'host'));
     $parser->addOption('confluence_space', array('long_name' => '--confluence-space', 'optional' => true, 'action' => 'StoreString', 'description' => 'Confluence space name', 'help_name' => 'space'));
     $parser->addOption('confluence_page', array('long_name' => '--confluence-page', 'optional' => true, 'action' => 'StoreString', 'description' => 'Confluence page name', 'help_name' => 'page'));
 }
开发者ID:netresearch,项目名称:deploy-rst,代码行数:17,代码来源:Confluence.php

示例6: createParser

 /**
  * Creates the command line parser and populates it with all allowed
  * options and parameters.
  *
  * @return Console_CommandLine CommandLine object
  */
 protected function createParser()
 {
     $parser = new Console_CommandLine();
     $parser->description = 'CLI interface to GeSHi, the generic syntax highlighter';
     $parser->version = '0.1.0';
     /*
     $parser->addOption('outfile', array(
         'short_name'  => '-o',
         'long_name'   => '--outfile',
         'description' => 'File to save output to',
         'help_name'   => 'FILE',
         'action'      => 'StoreString'
     ));
     */
     $parser->addOption('format', array('short_name' => '-f', 'long_name' => '--format', 'description' => 'Format of file to highlight (e.g. php).', 'help_name' => 'FORMAT', 'action' => 'StoreString', 'default' => false));
     $parser->addOption('renderer', array('short_name' => '-r', 'long_name' => '--renderer', 'description' => 'Renderer to use', 'help_name' => 'RENDERER', 'action' => 'StoreString', 'default' => 'html', 'choices' => array_keys(self::$arRenderers), 'list' => array_keys(self::$arRenderers), 'add_list_option' => true));
     $parser->addArgument('infile', array('help_name' => 'source file'));
     return $parser;
 }
开发者ID:rockylo,项目名称:geshi-1.1,代码行数:25,代码来源:geshi-cli.php

示例7: getParser

 /**
  * Returns a parser of the command line arguments.
  */
 function getParser()
 {
     require_once 'Console/CommandLine.php';
     $parser = new \Console_CommandLine(array('name' => 'hnu', 'description' => 'Photon command line manager.', 'version' => VERSION));
     $options = array('verbose' => array('short_name' => '-v', 'long_name' => '--verbose', 'action' => 'StoreTrue', 'description' => 'turn on verbose output'), 'conf' => array('long_name' => '--conf', 'action' => 'StoreString', 'help_name' => 'path/conf.php', 'description' => 'where the configuration is to be found. By default, the configuration file is the config.php in the current working directory'));
     foreach ($options as $name => $option) {
         $parser->addOption($name, $option);
     }
     $cmds = array('init' => array('desc' => 'generate the skeleton of a new Photon project in the current folder'), 'pot' => array('desc' => 'generate a standard gettext template file for the project (.pot)', 'opts' => array('potfile' => array('long_name' => '--pot-file', 'action' => 'StoreString', 'help_name' => 'myproject.pot', 'description' => 'Output filename for the gettext template'))), 'show-config' => array('desc' => 'Dump the config file on the standard output, usefull to show phar packaged configuration'), 'serve' => array('desc' => 'start a Photon handler server', 'opts' => array('server_id' => array('long_name' => '--server-id', 'action' => 'StoreString', 'help_name' => 'id', 'description' => 'set the Photon handler id'), 'daemonize' => array('long_name' => '--daemonize', 'action' => 'StoreTrue', 'description' => 'run as daemon'))), 'worker' => array('desc' => 'start a Photon worker', 'args' => array('task' => array('description' => 'the name of the worker task')), 'opts' => array('server_id' => array('long_name' => '--server-id', 'action' => 'StoreString', 'help_name' => 'id', 'description' => 'set the Photon task id'), 'daemonize' => array('long_name' => '--daemonize', 'action' => 'StoreTrue', 'description' => 'run as daemon'))), 'test' => array('desc' => 'run the tests of your project. Uses config.test.php as default config file', 'opts' => array('directory' => array('long_name' => '--coverage-html', 'action' => 'StoreString', 'help_name' => 'path/folder', 'description' => 'directory to store the code coverage report'), 'bootstrap' => array('long_name' => '--bootstrap', 'action' => 'StoreString', 'help_name' => 'path/bootstrap.php', 'description' => 'bootstrap PHP file given to PHPUnit. By default the photon/testbootstrap.php file'))), 'selftest' => array('desc' => 'run the Photon self test procedure', 'opts' => array('directory' => array('long_name' => '--coverage-html', 'action' => 'StoreString', 'help_name' => 'path/folder', 'description' => 'directory to store the code coverage report'))), 'package' => array('desc' => 'package a project as a standalone .phar file', 'args' => array('project' => array('description' => 'the name of the project')), 'opts' => array('conf_file' => array('long_name' => '--include-conf', 'action' => 'StoreString', 'help_name' => 'path/config.prod.php', 'description' => 'path to the configuration file used in production'), 'composer' => array('long_name' => '--composer', 'action' => 'StoreTrue', 'description' => 'Build a phar for the composer version of photon'), 'exclude_files' => array('long_name' => '--exclude-files', 'action' => 'StoreString', 'help_name' => '\\..*', 'description' => 'comma separated list of patterns matching files to exclude'))), 'makekey' => array('desc' => 'prints out a unique random secret key for your configuration', 'opts' => array('length' => array('long_name' => '--length', 'action' => 'StoreInt', 'description' => 'length of the generate secret key (64)'))));
     $def_cmd = array('opts' => array(), 'args' => array());
     foreach ($cmds as $name => $cmd) {
         $pcmd = $parser->addCommand($name, array('description' => $cmd['desc']));
         $cmd = array_merge($def_cmd, $cmd);
         foreach ($cmd['opts'] as $oname => $oinfo) {
             $pcmd->addOption($oname, $oinfo);
         }
         foreach ($cmd['args'] as $aname => $ainfo) {
             $pcmd->addArgument($aname, $ainfo);
         }
     }
     return $parser;
 }
开发者ID:photon,项目名称:photon,代码行数:25,代码来源:photon.php

示例8: _readCommandLineRequest

 protected function _readCommandLineRequest()
 {
     $parser = new Console_CommandLine();
     $parser->description = "Lion Framework " . LION_VERSION_NUMBER . ' (built: ' . LION_VERSION_BUILD_DATE . ")\n" . "An open source PHP Framework for rapid development of PHP web applications";
     $parser->version = LION_VERSION_NUMBER;
     $parser->addOption('clearcache', array('short_name' => '-c', 'long_name' => '--clearcache', 'description' => 'clear the cache', 'action' => 'StoreTrue'));
     // Adding an option that will store a string
     $parser->addOption('info', array('short_name' => '-i', 'long_name' => '--info', 'description' => 'show the runtime directives', 'action' => 'StoreTrue'));
     // Adding an option that will store a string
     $parser->addOption('bootstrap', array('short_name' => '-b', 'long_name' => '--bootstrap', 'description' => 'bootstrap a new application', 'action' => 'StoreTrue'));
     // Adding an option that will store a string
     $parser->addOption('controller', array('long_name' => '--controller', 'description' => 'executes the given controller', 'action' => 'StoreString'));
     // Adding an option that will store a string
     $parser->addOption('action', array('long_name' => '--action', 'description' => 'executes the given action', 'action' => 'StoreString'));
     return $parser;
 }
开发者ID:laiello,项目名称:lion-framework,代码行数:16,代码来源:CommandLineController.class.php

示例9: buildParser2

/**
 * Build a parser instance and return it.
 *
 * @return object Console_CommandLine instance
 */
function buildParser2()
{
    $parser = new Console_CommandLine();
    $parser->name = 'some_program';
    $parser->version = '0.1.0';
    $parser->description = 'Description of our parser goes here...';
    // add general options
    $parser->addOption('verbose', array('short_name' => '-v', 'long_name' => '--verbose', 'action' => 'StoreTrue', 'description' => 'verbose mode'));
    $parser->addOption('logfile', array('short_name' => '-l', 'long_name' => '--logfile', 'action' => 'StoreString', 'description' => 'path to logfile'));
    // install subcommand
    $cmd1 = $parser->addCommand('install', array('description' => 'install given package'));
    $cmd1->addOption('force', array('short_name' => '-f', 'long_name' => '--force', 'action' => 'StoreTrue', 'description' => 'force installation'));
    $cmd1->addArgument('package', array('description' => 'package to install'));
    // uninstall subcommand
    $cmd2 = $parser->addCommand('uninstall', array('description' => 'uninstall given package'));
    $cmd2->addArgument('package', array('description' => 'package to uninstall'));
    return $parser;
}
开发者ID:hnw,项目名称:php425,代码行数:23,代码来源:tests.inc.php

示例10: getCommandLineParser

 /**
  * Gets the CLI parser for this pinentry
  *
  * @return Console_CommandLine the CLI parser for this pinentry.
  */
 protected function getCommandLineParser()
 {
     return Console_CommandLine::fromXmlFile($this->getUIXML());
 }
开发者ID:remicollet,项目名称:Crypt_GPG,代码行数:9,代码来源:PinEntry.php

示例11: Console_CommandLine

 * through the world-wide-web at the following URI:
 * http://opensource.org/licenses/mit-license.php
 *
 * @category  Console 
 * @package   Console_CommandLine
 * @author    David JEAN LOUIS <izimobil@gmail.com>
 * @copyright 2007 David JEAN LOUIS
 * @license   http://opensource.org/licenses/mit-license.php MIT License 
 * @version   CVS: $Id$
 * @link      http://pear.php.net/package/Console_CommandLine
 * @since     File available since release 0.1.0
 */
// Include the Console_CommandLine package.
require_once 'Console/CommandLine.php';
// create the parser
$parser = new Console_CommandLine(array('description' => 'zip given files using the php zip module.', 'version' => '1.0.0'));
// add an option to make the program verbose
$parser->addOption('verbose', array('short_name' => '-v', 'long_name' => '--verbose', 'action' => 'StoreTrue', 'description' => 'turn on verbose output'));
// add an option to delete original files after zipping
$parser->addOption('delete', array('short_name' => '-d', 'long_name' => '--delete', 'action' => 'StoreString', 'description' => 'delete original files after zip operation', 'choices' => array('foo', 'bar'), 'add_list_option' => true));
// add the files argument, the user can specify one or several files
$parser->addArgument('files', array('multiple' => true, 'description' => 'list of files to zip separated by spaces'));
// add the zip file name argument
$parser->addArgument('zipfile', array('description' => 'zip file name'));
// run the parser
try {
    $result = $parser->parse();
    // write your program here...
    print_r($result->options);
    print_r($result->args);
} catch (Exception $exc) {
开发者ID:liujingyu,项目名称:phpuml,代码行数:31,代码来源:ex1.php

示例12: Console_CommandLine

#!/usr/bin/env php
<?php 
/**
 * Verify Phar archive signature using a public key file
 *
 * This file is part of the PharUtil library.
 * @author Krzysztof Kotowicz <kkotowicz at gmail dot com>
 * @package PharUtil
 */
// Include the Console_CommandLine package.
require_once 'Console/CommandLine.php';
require_once 'PharUtil/RemotePharVerifier.php';
// create the parser
$parser = new Console_CommandLine(array('description' => 'Verify Phar archive signature using a public key file', 'version' => '@package_version@', 'name' => 'phar-verify'));
$parser->addOption('public', array('short_name' => '-P', 'long_name' => '--public', 'action' => 'StoreString', 'default' => './cert/pub.pem', 'description' => "Public key file (PEM) to verify signature\n(./cert/pub.pem by default)"));
$parser->addOption('nosign', array('short_name' => '-n', 'long_name' => '--ns', 'action' => 'StoreTrue', 'description' => 'Archive is not signed, don\'t require an OpenSSL signature'));
$parser->addOption('temp', array('short_name' => '-t', 'long_name' => '--temp', 'action' => 'StoreString', 'description' => 'Temporary directory (' . sys_get_temp_dir() . ' by default)'));
$parser->addArgument('phar', array('action' => 'StoreString', 'description' => "Input Phar archive URI e.g.\n/path/to/local/phar.phar or http://path/to/remote/phar.phar"));
// run the parser
try {
    $result = $parser->parse();
} catch (Exception $exc) {
    $parser->displayError($exc->getMessage());
}
$options = $result->options;
$args = $result->args;
echo $parser->name . ' ' . $parser->version . PHP_EOL . PHP_EOL;
// validate parameters
if (substr($args['phar'], -5) !== '.phar') {
    $parser->displayError("Input Phar must have .phar extension, {$args['phar']} given.", 2);
}
开发者ID:richarrj,项目名称:phar-util,代码行数:31,代码来源:phar-verify.php

示例13: define

 */
/**
 * @copyright Copyright 2010-2011
 * @author Edward Rudd <urkle at outoforder.cc>
 */
if (!defined('__DIR__')) {
    define('__DIR__', dirname(__FILE__));
}
// Pull in the configuration file.. (Yes this actually works)
$config = (include __DIR__ . "/config.php");
// Set debugging if enabled
define('DEBUG', !empty($config->debug));
// Load up the class auto loader
require_once __DIR__ . "/../classes/Init.php";
include "common.php";
$parser = new Console_CommandLine();
$parser->description = "Convers the raw spell icons into strips for the trainer";
$parser->version = "0.0.1";
$parser->addOption('newsize', array('long_name' => '--size', 'description' => 'Size of new icons', 'default' => 64, 'help_name' => 'SIZE', 'action' => 'StoreInt'));
$parser->addOption('prefix', array('long_name' => '--prefix', 'description' => 'The output filename prefix', 'default' => 'trainer-icon-', 'help_name' => 'PREFIX'));
$parser->addArgument('mapfile', array('description' => 'The input JSON map file process', 'help_name' => 'INPUTFILE'));
$parser->addArgument('outputdir', array('description' => 'The output dir for images', 'help_name' => 'OUTPUTDIR'));
try {
    $args = $parser->parse();
} catch (Exception $ex) {
    $parser->displayError($ex->getMessage());
}
$map = json_decode(file_get_contents($args->args['mapfile']));
$size = $args->options['newsize'];
$imagedir = dirname($args->args['mapfile']);
$imageunused = $imagedir . DIRECTORY_SEPARATOR . 'unused';
开发者ID:Anpu,项目名称:INQ-Calculators,代码行数:31,代码来源:trainer.php

示例14: run

 /**
  * Process the request
  *
  * @param array $params Runner options
  *
  * @return void
  */
 public function run($params = null)
 {
     $this->parser = new Parser($this->paths);
     try {
         $argc = $params === null ? null : count($params);
         $this->result = $this->parser->parse($argc, $params);
     } catch (\Exception $e) {
         $this->parser->displayError($e->getMessage());
     }
     $this->parse();
 }
开发者ID:negativespace,项目名称:phrozn,代码行数:18,代码来源:CommandLine.php

示例15: getArgcArgv

 protected function getArgcArgv()
 {
     if (empty($this->commands)) {
         return parent::getArgcArgv();
     }
     list($argc, $argv) = parent::getArgcArgv();
     // Obtain the list of options
     $opts = array();
     foreach ($this->options as $opt) {
         $opts[] = $opt->short_name;
         $opts[] = $opt->long_name;
     }
     // Get commands
     $commands = array();
     foreach ($this->commands as $cmd) {
         $commands[] = $cmd->name;
         $commands = array_merge($commands, $cmd->aliases);
     }
     // Inject default command if none given
     $commands = array_keys($this->commands);
     for ($i = 1; $i < $argc; $i++) {
         if (!in_array($argv[$i], $opts) && !in_array($argv[$i], $commands)) {
             array_splice($argv, $i, 0, $commands[0]);
             $argc++;
             break;
         }
     }
     return array($argc, $argv);
 }
开发者ID:rafeca,项目名称:Spec-PHP,代码行数:29,代码来源:CommandLine.php


注:本文中的Console_CommandLine类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。