本文整理汇总了PHP中Zend_Console_Getopt::getUsageMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Console_Getopt::getUsageMessage方法的具体用法?PHP Zend_Console_Getopt::getUsageMessage怎么用?PHP Zend_Console_Getopt::getUsageMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Console_Getopt
的用法示例。
在下文中一共展示了Zend_Console_Getopt::getUsageMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildErrors
protected function buildErrors()
{
if ($this->hasErrors()) {
echo implode("\n", $this->getErrors());
echo $this->opts->getUsageMessage();
}
}
示例2: array
function __construct($process_classes_folder)
{
$this->Logger = \Logger::getLogger('JobLauncher');
$processes = @glob("{$process_classes_folder}/class.*Process.php");
$options = array();
if (count($processes) > 0) {
foreach ($processes as $process) {
$filename = basename($process);
$directory = dirname($process);
if (!file_exists($directory . "/" . $filename)) {
throw new \Exception(sprintf("File %s does not exist.", $directory . "/" . $filename));
}
include_once $directory . "/" . $filename;
preg_match("/class.(.*)Process.php/s", $filename, $tmp);
$process_name = $tmp[1];
if (class_exists("{$process_name}Process")) {
$reflect = new \ReflectionClass("{$process_name}Process");
if ($reflect) {
if ($reflect->implementsInterface('Scalr\\System\\Pcntl\\ProcessInterface')) {
$options[$process_name] = $reflect->getProperty("ProcessDescription")->getValue($reflect->newInstance());
} else {
throw new \Exception("Class '{$process_name}Process' doesn't implement 'ProcessInterface'.", E_ERROR);
}
} else {
throw new \Exception("Cannot use ReflectionAPI for class '{$process_name}Process'", E_ERROR);
}
} else {
throw new \Exception("'{$process}' does not contain definition for '{$process_name}Process'", E_ERROR);
}
}
} else {
throw new \Exception(_("No job classes found in {$process_classes_folder}"), E_ERROR);
}
$options["help"] = "Print this help";
$options["piddir=s"] = "PID directory";
$Getopt = new \Zend_Console_Getopt($options);
try {
$opts = $Getopt->getOptions();
} catch (\Zend_Console_Getopt_Exception $e) {
print "{$e->getMessage()}\n\n";
die($Getopt->getUsageMessage());
}
if (in_array("help", $opts) || count($opts) == 0 || !$options[$opts[0]]) {
print $Getopt->getUsageMessage();
exit;
} else {
$this->ProcessName = $opts[0];
/*
if (in_array("piddir", $opts)) {
$piddir = trim($Getopt->getOption("piddir"));
if (substr($piddir, 0, 1) != '/') {
//$this->PIDDir = realpath($process_classes_folder . "/" . $piddir);
} else {
//$this->PIDDir = $piddir;
}
}
*/
}
}
示例3: handle
/**
* handler for command line scripts
*
* @return boolean
*/
public function handle()
{
try {
$opts = new Zend_Console_Getopt(array('help|h' => 'Display this help Message', 'verbose|v' => 'Output messages', 'config|c=s' => 'Path to config.inc.php file', 'setconfig' => 'Update config. To specify the key and value, append \' -- configKey="your_key" configValue="your config value"\'
Examples:
setup.php --setconfig -- configkey=sample1 configvalue=value11
setup.php --setconfig -- configkey=sample2 configvalue=arrayKey1:Value1,arrayKey2:value2', 'check_requirements' => 'Check if all requirements are met to install and run tine20', 'create_admin' => 'Create new admin user (or reactivate if already exists)', 'install-s' => 'Install applications [All] or comma separated list;' . ' To specify the login name and login password of the admin user that is created during installation, append \' -- adminLoginName="admin" adminPassword="password"\'' . ' To add imap or smtp settings, append (for example) \' -- imap="host:mail.example.org,port:143,dbmail_host:localhost" smtp="ssl:tls"\'', 'update-s' => 'Update applications [All] or comma separated list', 'uninstall-s' => 'Uninstall application [All] or comma separated list', 'list-s' => 'List installed applications', 'sync_accounts_from_ldap' => 'Import user and groups from ldap', 'egw14import' => 'Import user and groups from egw14
Examples:
setup.php --egw14import egwdbhost egwdbuser egwdbpass egwdbname latin1
setup.php --egw14import egwdbhost egwdbuser egwdbpass egwdbname utf8'));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo "Invalid usage: {$e->getMessage()}\n\n";
echo $e->getUsageMessage();
exit;
}
if (count($opts->toArray()) === 0 || $opts->h || empty($opts->install) && empty($opts->update) && empty($opts->uninstall) && empty($opts->list) && empty($opts->sync_accounts_from_ldap) && empty($opts->egw14import) && empty($opts->check_requirements) && empty($opts->create_admin) && empty($opts->setconfig)) {
echo $opts->getUsageMessage();
exit;
}
if ($opts->config) {
// add path to config.inc.php to include path
$path = strstr($opts->config, 'config.inc.php') !== false ? dirname($opts->config) : $opts->config;
set_include_path($path . PATH_SEPARATOR . get_include_path());
}
Setup_Core::initFramework();
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Is cli request. method: ' . (isset($opts->mode) ? $opts->mode : 'EMPTY'));
}
$setupServer = new Setup_Frontend_Cli();
#$setupServer->authenticate($opts->username, $opts->password);
return $setupServer->handle($opts);
}
示例4: index
public function index()
{
try {
$opts = new Zend_Console_Getopt(array('help|h' => 'Displays usage information', 'profiling|p' => 'Turn on Magento\'s profiler', 'database|d' => 'Turn on profiling of db queries'));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
$this->out('I do apologise! ' . $e->getMessage(), "red");
echo "\n" . str_replace("magentleman", "magentleman console", $e->getUsageMessage()) . "\n";
exit;
}
// Help action
if (isset($opts->help)) {
$this->out("It's terribly simple to use me:", "green");
echo "\n";
echo str_replace("magentleman", "magentleman console", $opts->getUsageMessage());
echo "\n";
exit;
}
if (isset($opts->profiling)) {
$this->profiling = true;
}
if (isset($opts->database)) {
$this->database = true;
}
$this->clear();
$this->out("");
$this->out(" " . $this->greeting, "green");
$this->out(" To get help using this console, visit our website at http://www.qipcreative.com/magentleman\n", "yellow");
$this->startConsole();
}
示例5: routeStartup
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
try {
$opts = new Zend_Console_Getopt(array('controller|c=s' => 'Name of the controller to open', 'action|a=s' => 'The command line action to execute', 'cityId|ci=i' => 'City id to get trend data for', 'startDate|sd=s' => 'Start date for the price trends', 'endDate|ed=s' => 'End date for the price trends', 'hours|h=i' => 'How many hours to simulate for'));
$opts->parse();
$args = $opts->getRemainingArgs();
if (!isset($opts->action)) {
throw new Zend_Console_Getopt_Exception('Action parameter missing');
}
$cliAction = $opts->action;
$cliController = $opts->controller;
$paramters = array();
$optArray = $opts->toArray();
for ($i = 0; $i < count($optArray); $i += 2) {
$paramters[$optArray[$i]] = $optArray[$i + 1];
}
} catch (Zend_Console_Getopt_Exception $e) {
echo $opts->getUsageMessage();
exit;
}
// set the request as a CLI request
$request = new Zend_Controller_Request_Simple($cliAction, $cliController, 'cli');
foreach ($paramters as $key => $paramVal) {
$request->setParam($key, $paramVal);
}
foreach ($args as $argument) {
$request->setParam($argument, true);
}
$response = new Zend_Controller_Response_Cli();
$front = Zend_Controller_Front::getInstance();
$front->setRequest($request)->setResponse($response);
}
示例6: __construct
/**
* 构造函数,初始化日志文件目录。
*/
protected function __construct()
{
try {
$console = new Zend_Console_Getopt(array('logroot|l=s' => 'the Log Server root directory', 'logdir|d=s' => 'this log file directory', 'logfile|f=s' => 'the log files', 'delay|a=i' => 'delay timestamp', 'start|s=s' => 'start datetime', 'end|e=s' => 'end datetime'));
if (!$console->getOptions()) {
throw new ZtChart_Model_Monitor_Console_Exception($console->getUsageMessage());
}
if (null !== ($logServerRootDirectory = $console->getOption('l'))) {
foreach (array_diff(scandir($logServerRootDirectory), array('.', '..')) as $directory) {
$this->_logDirectories[] = realpath($logServerRootDirectory) . DIRECTORY_SEPARATOR . $directory;
}
}
if (null !== ($logDirectories = $console->getOption('d'))) {
$this->_logDirectories += $logDirectories;
}
if (null !== ($logFiles = $console->getOption('f'))) {
$this->_logFiles = explode(' ', $logFiles);
}
if (null !== ($delayTimestamp = $console->getOption('a'))) {
$this->_delayTimestamp = $delayTimestamp;
}
if (null !== ($startTimestamp = $console->getOption('s'))) {
$this->_startTimestamp = $startTimestamp;
}
if (null !== ($endTimestamp = $console->getOption('e'))) {
$this->_endTimestamp = $endTimestamp;
}
} catch (Zend_Console_Getopt_Exception $e) {
throw new ZtChart_Model_Monitor_Console_Exception($e->getMessage());
}
$this->_console = $console;
}
示例7: buildErrors
/**
* Method build and show error message
*
* @return \Extlib\Cli\CliAbstract
*/
protected function buildErrors()
{
if ($this->hasErrors()) {
echo implode(PHP_EOL, $this->getErrors());
echo PHP_EOL, $this->opts->getUsageMessage();
}
return $this;
}
示例8: dispatch
/**
* Dispatch the lighter application.
*
* @throws Exception
*/
public function dispatch()
{
if ($this->console->getOption('help')) {
echo $this->console->getUsageMessage();
} elseif ($this->app !== null) {
$this->createProject();
} else {
throw new Exception('A name for the application are required failure.');
}
}
示例9: _steps
/**
* @return void
*/
private function _steps()
{
$steps = $this->getSteps();
foreach ($steps as $step) {
if (false === in_array($step, $this->_stepsOptionsArgs)) {
$usage = $this->_opts->getUsageMessage();
$message = 'Option "step" requires only this parameters: ' . "\"{$this->_getStepsOptions()}\" or \"all\" " . "but was given \"{$step}\"" . (count($steps) > 1 ? " from \"{$this->_getArg('step')}.\"" : '.');
throw new \Zend_Console_Getopt_Exception($message, $usage);
}
}
}
示例10: route
public function route(Zend_Controller_Request_Abstract $dispatcher)
{
try {
$opts = new Zend_Console_Getopt(array('help|h' => 'prints this usage information', 'action|a=s' => 'action name (default: index)', 'controller|c=s' => 'controller name (default: index)', 'verbose|v' => 'explain what is being done'));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getMessage() . "\n\n" . $e->getUsageMessage();
exit(1);
}
if ($opts->getOption("help")) {
echo $opts->getUsageMessage();
exit;
}
if (!$opts->getOption("action")) {
$opts->setOption("action", "index");
}
if (!$opts->getOption("controller")) {
$opts->setOption("controller", "index");
}
$dispatcher->setControllerName($opts->getOption("controller"))->setActionName($opts->getOption("action"));
}
示例11: handle
/**
* (non-PHPdoc)
* @see Tinebase_Server_Interface::handle()
*/
public function handle(\Zend\Http\Request $request = null, $body = null)
{
try {
$opts = new Zend_Console_Getopt(array('help|h' => 'Display this help Message', 'verbose|v' => 'Output messages', 'config|c=s' => 'Path to config.inc.php file', 'setconfig' => 'Update config. To specify the key and value, append \' -- configkey="your_key" configValue="your config value"\'
Examples:
setup.php --setconfig -- configkey=sample1 configvalue=value11
setup.php --setconfig -- configkey=sample2 configvalue=arrayKey1:Value1,arrayKey2:value2
', 'getconfig' => 'Get Config value for a specify the key \' -- configkey="your_key"\'', 'check_requirements' => 'Check if all requirements are met to install and run tine20', 'create_admin' => 'Create new admin user (or reactivate if already exists)', 'install-s' => 'Install applications [All] or comma separated list;' . ' To specify the login name and login password of the admin user that is created during installation, append \' -- adminLoginName="admin" adminPassword="password"\'' . ' To add imap or smtp settings, append (for example) \' -- imap="host:mail.example.org,port:143,dbmail_host:localhost" smtp="ssl:tls"\'', 'update-s' => 'Update applications [All] or comma separated list', 'uninstall-s' => 'Uninstall application [All] or comma separated list', 'list-s' => 'List installed applications', 'sync_accounts_from_ldap' => 'Import user and groups from ldap', 'dbmailldap' => 'Only usable with sync_accounts_from_ldap. Fetches dbmail email user data from LDAP.', 'onlyusers' => 'Only usable with sync_accounts_from_ldap. Fetches only users and no groups from LDAP.', 'syncdeletedusers' => 'Only usable with sync_accounts_from_ldap. Removes users from Tine 2.0 DB that no longer exist in LDAP', 'syncaccountstatus' => 'Only usable with sync_accounts_from_ldap. Synchronizes current account status from LDAP', 'syncontactphoto' => 'Only usable with sync_accounts_from_ldap. Always syncs contact photo from ldap', 'sync_passwords_from_ldap' => 'Synchronize user passwords from ldap', 'egw14import' => 'Import user and groups from egw14
Examples:
setup.php --egw14import /path/to/config.ini', 'reset_demodata' => 'reinstall applications and install Demodata (Needs Admin user)', 'updateAllImportExportDefinitions' => 'update ImportExport definitions for all applications', 'backup' => 'backup config and data
Examples:
setup.php --backup -- config=1 db=1 files=1 backupDir=/backup/tine20 noTimestamp=1', 'restore' => 'restore config and data
Examples:
setup.php --restore -- config=1 db=1 files=1 backupDir=/backup/tine20'));
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo "Invalid usage: {$e->getMessage()}\n\n";
echo $e->getUsageMessage();
exit;
}
if (count($opts->toArray()) === 0 || $opts->h || empty($opts->install) && empty($opts->update) && empty($opts->uninstall) && empty($opts->list) && empty($opts->sync_accounts_from_ldap) && empty($opts->sync_passwords_from_ldap) && empty($opts->egw14import) && empty($opts->check_requirements) && empty($opts->reset_demodata) && empty($opts->updateAllImportExportDefinitions) && empty($opts->create_admin) && empty($opts->setconfig) && empty($opts->backup) && empty($opts->restore) && empty($opts->getconfig)) {
echo $opts->getUsageMessage();
exit;
}
if ($opts->config) {
// add path to config.inc.php to include path
$path = strstr($opts->config, 'config.inc.php') !== false ? dirname($opts->config) : $opts->config;
set_include_path($path . PATH_SEPARATOR . get_include_path());
}
Setup_Core::initFramework();
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Is cli request. method: ' . $this->getRequestMethod());
}
$setupServer = new Setup_Frontend_Cli();
#$setupServer->authenticate($opts->username, $opts->password);
return $setupServer->handle($opts);
}
示例12: dirname
* @package OpenSKOS
* @copyright Copyright (c) 2015 Pictura Database Publishing. (http://www.pictura-dp.nl)
* @author Alexandar Mitsev
* @license http://www.gnu.org/licenses/gpl-3.0.txt GPLv3
*/
include dirname(__FILE__) . '/../autoload.inc.php';
/*
* Updates the status expired to status obsolete
*/
require_once 'Zend/Console/Getopt.php';
$opts = array('env|e=s' => 'The environment to use (defaults to "production")');
try {
$OPTS = new Zend_Console_Getopt($opts);
} catch (Zend_Console_Getopt_Exception $e) {
fwrite(STDERR, $e->getMessage() . "\n");
echo str_replace('[ options ]', '[ options ] action', $OPTS->getUsageMessage());
exit(1);
}
include dirname(__FILE__) . '/../bootstrap.inc.php';
// Allow loading of application module classes.
$autoloader = new OpenSKOS_Autoloader();
$mainAutoloader = Zend_Loader_Autoloader::getInstance();
$mainAutoloader->pushAutoloader($autoloader, array('Editor_', 'Api_'));
// Concepts
$conceptsCounter = 0;
$response = Api_Models_Concepts::factory()->getConcepts('status:' . OpenSKOS_Concept_Status::_EXPIRED, true);
if (isset($response['response']['docs'])) {
foreach ($response['response']['docs'] as $doc) {
$concept = new Editor_Models_Concept(new Api_Models_Concept($doc));
$concept->update([], ['status' => OpenSKOS_Concept_Status::OBSOLETE], true, true);
$conceptsCounter++;
示例13: testGetoptSetHelpInvalid
public function testGetoptSetHelpInvalid()
{
$opts = new Zend_Console_Getopt('abp:', array('-a'));
$opts->setHelp(array('a' => 'apple', 'b' => 'banana', 'p' => 'pear', 'c' => 'cumquat'));
$message = preg_replace('/Usage: .* \\[ options \\]/', 'Usage: <progname> [ options ]', $opts->getUsageMessage());
$message = preg_replace('/ /', '_', $message);
$this->assertEquals($message, "Usage:_<progname>_[_options_]\n-a___________________apple\n-b___________________banana\n-p_<string>__________pear\n");
}
示例14: realpath
}
require_once realpath(APPLICATION_PATH . '/../vendor/autoload.php');
$paths = array(realpath(APPLICATION_PATH . '/../library'), get_include_path());
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, $paths));
// A list of all possible source environments
$possibleSources = array('production', 'staging', 'development', 'nonproduction', 'testing');
// A list of all possible destination environments
$possibleDestinations = array('staging', 'development', 'nonproduction', 'testing');
// Sets up the expected options
$opts = new Zend_Console_Getopt(array('source|s=s' => 'Source DB Environment (' . implode($possibleSources, ', ') . ')', 'destination|d=s' => 'Destination DB Environment (' . implode($possibleDestinations, ', ') . ')'));
// Get all available options and does some validity checking
try {
$opts->parse();
} catch (Exception $e) {
Ot_Cli_Output::error($opts->getUsageMessage());
}
if (!isset($opts->source) || !in_array($opts->source, $possibleSources)) {
Ot_Cli_Output::error('Source not sepecified or not available' . "\n\n" . $opts->getUsageMessage());
}
if (!isset($opts->destination) || !in_array($opts->destination, $possibleDestinations)) {
Ot_Cli_Output::error('Destination not sepecified or not available' . "\n\n" . $opts->getUsageMessage());
}
if ($opts->source == $opts->destination) {
Ot_Cli_Output::error('Source and Destination cannot be the same' . "\n\n" . $opts->getUsageMessage());
}
$source = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', $opts->source);
$destination = new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', $opts->destination);
if (!isset($source->resources->db)) {
Ot_Cli_Output::error('No DB information found in source' . "\n\n" . $opts->getUsageMessage());
}
示例15: array
}
}
// Setup autoloading
$loader = new Zend_Loader_StandardAutoloader();
$loader->setFallbackAutoloader(true);
$loader->register();
$rules = array('help|h' => 'Get usage message', 'library|l-s' => 'Library to parse; if none provided, assumes current directory', 'output|o-s' => 'Where to write autoload file; if not provided, assumes "autoload_classmap.php" in library directory', 'overwrite|w' => 'Whether or not to overwrite existing autoload file');
try {
$opts = new Zend_Console_Getopt($rules);
$opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
echo $e->getUsageMessage();
exit(2);
}
if ($opts->getOption('h')) {
echo $opts->getUsageMessage();
exit;
}
$path = $libPath;
if (array_key_exists('PWD', $_SERVER)) {
$path = $_SERVER['PWD'];
}
if (isset($opts->l)) {
$path = $opts->l;
if (!is_dir($path)) {
echo "Invalid library directory provided" . PHP_EOL . PHP_EOL;
echo $opts->getUsageMessage();
exit(2);
}
$path = realpath($path);
}