Exemplo n.º 1
0
 protected function buildErrors()
 {
     if ($this->hasErrors()) {
         echo implode("\n", $this->getErrors());
         echo $this->opts->getUsageMessage();
     }
 }
Exemplo n.º 2
0
 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;
             }
         }
         */
     }
 }
Exemplo n.º 3
0
 /**
  * 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="******"\'' . ' 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);
 }
Exemplo n.º 4
0
 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();
 }
Exemplo n.º 5
0
 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);
 }
Exemplo n.º 6
0
 /**
  * 构造函数,初始化日志文件目录。
  */
 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;
 }
 /**
  * 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;
 }
Exemplo n.º 8
0
 /**
  * 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.');
     }
 }
Exemplo n.º 9
0
 /**
  * @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);
         }
     }
 }
Exemplo n.º 10
0
 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"));
 }
 /**
  * (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="******"\'' . ' 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);
 }
 * @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++;
Exemplo n.º 13
0
 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");
 }
Exemplo n.º 14
0
}
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());
}
Exemplo n.º 15
0
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright  Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license    http://opensource.org/licenses/osl-3.0.php  Open Software License (OSL 3.0)
 */
require __DIR__ . '/bootstrap.php';
use Magento\Tools\I18n\Code\ServiceLocator;
try {
    $console = new \Zend_Console_Getopt(array('source|s=s' => 'Path to source dictionary file with translations', 'pack|p=s' => 'Path to language package', 'locale|l=s' => 'Target locale for dictionary, for example "de_DE"', 'mode|m-s' => 'Save mode for dictionary
        - "replace" - replace language pack by new one
        - "merge" -  merge language packages, by default "replace"', 'allow_duplicates|d=s' => 'Is allowed to save duplicates of translate, by default "no"'));
    $console->parse();
    if (!count($console->getOptions())) {
        throw new \UnexpectedValueException('Required parameters are missed, please see usage description' . "\n\n" . $console->getUsageMessage());
    }
    $dictionaryPath = $console->getOption('source');
    $packPath = $console->getOption('pack');
    $locale = $console->getOption('locale');
    $allowDuplicates = in_array($console->getOption('allow_duplicates'), array('y', 'Y', 'yes', 'Yes', '1'));
    $saveMode = $console->getOption('mode');
    if (!$dictionaryPath) {
        throw new \Zend_Console_Getopt_Exception('Dictionary source path parameter is required.');
    }
    if (!$packPath) {
        throw new \Zend_Console_Getopt_Exception('Pack path parameter is required.');
    }
    if (!$locale) {
        throw new \Zend_Console_Getopt_Exception('Locale parameter is required.');
    }
Exemplo n.º 16
0
    }
}
// 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);
}
/**
 * This function will look at the given program arguments and will validate them.
 * If the required arguments have been passed then it will call the config detector function,
 * otherwise it will stop the program.
 * This function is called at the end of this script (see last line of this file).
 * The help text below describes the arguments that are needed.
 */
function parseArgs()
{
    $rules = array('sourceDir|d=s' => 'Required. The base directory that the project resides in', 'outputDbFileName|o-s' => 'Optional. If given, the output will be written to the given file. If not given, output goes to STDOUT.', 'help|h' => 'This help message');
    $opts = new Zend_Console_Getopt($rules);
    // trim any quotes
    $sourceDir = trim($opts->getOption('sourceDir'), " \r\n\t'\"");
    $outputDbFileName = trim($opts->getOption('outputDbFileName'), " \r\n\t'\"");
    $help = trim($opts->getOption('help'), " \r\n\t'\"");
    if ($help) {
        $helpMessage = <<<EOF
The goal of this script is to discover all of the config files for your PHP Code Igniter projects. This means
that it will list all of the confi files for all of the projects. This script
will be called via a command line; it is a normal command line script.

This script is part of Triumph's Config Detection feature; it enables the editor to have a 
list of all of a project's config files so that the user can easily open / jump to them. More
info can be about Triumph's config detector feature can be found at 
http://docs.triumph4php.com/config-detectors/


When a required argument is invalid or missing, the program will exit with an error code (-1)

EOF;
        echo $helpMessage;
        echo "\n";
        echo $opts->getUsageMessage();
        exit(-1);
    }
    if (!$sourceDir) {
        echo "Missing argument: --sourceDir. See --help for details.\n";
        exit(-1);
    }
    if (!is_dir($sourceDir)) {
        echo "sourceDir is not a valid directory. Is \"{$sourceDir}\" a directory? Is it readable? \n";
        exit(-1);
    }
    if (!extension_loaded('pdo_sqlite') || !extension_loaded('PDO')) {
        echo "The script " . basename(__FILE__) . " requires the PDO and pdo_sqlite PHP extensions.";
        exit(-1);
    }
    // call the function that will return all detected configs
    $doSkip = TRUE;
    $arrConfigTags = detectConfigs($sourceDir, $doSkip);
    if ($doSkip) {
        echo "Detector " . basename(__FILE__, '.php') . " cannot detect configs for {$sourceDir} ... skipping\n";
    } else {
        if ($outputDbFileName) {
            // now send the detected URLs to either STDOUT or store in the
            // sqlite DB
            $pdo = Zend_Db::factory('Pdo_Sqlite', array("dbname" => $outputDbFileName));
            $configTagTable = new Triumph_ConfigTagTable($pdo);
            $configTagTable->saveConfigTags($arrConfigTags, $sourceDir);
            echo "Config dectection complete, written to {$outputDbFileName}\n";
        } else {
            if (!empty($arrConfigTags)) {
                echo str_pad("Label", 60) . str_pad("Full Path", 90) . "\n";
                foreach ($arrConfigTags as $url) {
                    echo str_pad($url->label, 60);
                    echo str_pad($url->fullPath, 90);
                    echo "\n";
                }
            } else {
                echo "No configs were detected for {$sourceDir}\n";
            }
        }
    }
}
Exemplo n.º 18
0
 /**
  * Delete a partner
  *
  * This is the delete action method. It allows you to delete a partner.
  *
  * @return void
  */
 public function deleteAction()
 {
     $this->_helper->viewRenderer->setViewSuffix('txt');
     // The options we are accepting for deleting
     $options = new Zend_Console_Getopt(array('email|e=s' => $this->tr->_('EMAIL_USERNAME')));
     try {
         $options->parse();
     } catch (Zend_Console_Getopt_Exception $e) {
         $this->view->message = $e->getUsageMessage();
         return;
     }
     if ($options->email == '') {
         echo $options->getUsageMessage();
         exit;
     }
     $partner_email = strtolower($options->email);
     $model = new Default_Model_Partner();
     $tempPartners = $model->getAll();
     $partner_id = null;
     foreach ($tempPartners as $key => $value) {
         if ($partner_email == $value['email']) {
             $partner_id = $value['hash'];
             break;
         }
     }
     if (!$partner_id) {
         $this->view->message = $this->tr->_('COULD_NOT_DELETE_PARTNER') . ': ' . $partner_email . '. ' . $this->tr->_('COULD_NOT_FIND_MATCH') . PHP_EOL;
         return;
     }
     try {
         $model->delete($partner_id);
         $this->view->message = $this->tr->_('SUCCESS_DELETE_PARTNER') . ': ' . $partner_email . PHP_EOL;
     } catch (RuntimeException $e) {
         $this->view->message = $this->tr->_('ERROR_DELETING_PARTNER') . ': ' . $partner_email . '. ' . $e->getMessage() . PHP_EOL;
     }
 }
/**
 * This function will look at the given program arguments and will validate them.
 * If the required arguments have been passed then it will call the template detector function,
 * otherwise it will stop the program.
 * This function is called at the end of this script (see last line of this file).
 * The help text below describes the arguments that are needed.
 */
function parseArgs()
{
    $rules = array('sourceDir|d=s' => 'Required. The base directory that the project resides in', 'detectorDbFileName|i=s' => 'Required. SQLite file that contains the call stack to examine. This file is created by ' . 'Triumph; Triumph performs INSERTs as it generates a call stack.', 'outputDbFileName|o-s' => 'Optional. If given, the output will be written to the given file. If not given, output goes to STDOUT.', 'help|h' => 'This help message');
    $opts = new Zend_Console_Getopt($rules);
    // trim any quotes
    $sourceDir = trim($opts->getOption('sourceDir'), " \r\n\t'\"");
    $detectorDbFileName = trim($opts->getOption('detectorDbFileName'), " \r\n\t'\"");
    $outputDbFileName = trim($opts->getOption('outputDbFileName'), " \r\n\t'\"");
    $help = trim($opts->getOption('help'), " \r\n\t'\"");
    if ($help) {
        $helpMessage = <<<EOF
The goal of this script is to discover template files for your PHP Laravel projects. This means
that given a triumph call stack, this script will list all of the template files that are used by the 
given controller functions. This script will be called via a command line; it is a normal command line script.

This script is part of Triumph's Template Files Detection feature; it enables the editor to have a 
list of all of a project's template files so that the user can easily open / jump to templates. More
info can be about Triumph's template file detector feature can be found at 
http://docs.triumph4php.com/template-file-detectors/

When a required argument is invalid or missing, the program will exit with an error code (-1)

EOF;
        echo $helpMessage;
        echo "\n";
        echo $opts->getUsageMessage();
        exit(-1);
    }
    if (!$sourceDir) {
        echo "Missing argument: --sourceDir. See --help for details.\n";
        exit(-1);
    }
    if (!is_dir($sourceDir)) {
        echo "sourceDir is not a valid directory. Is \"{$sourceDir}\" a directory? Is it readable? \n";
        exit(-1);
    }
    if (!$detectorDbFileName) {
        echo "Missing argument: --detectorDbFileName. See --help for details.\n";
        exit(-1);
    }
    if (!extension_loaded('pdo_sqlite') || !extension_loaded('PDO')) {
        echo "The script " . basename(__FILE__) . " requires the PDO and pdo_sqlite PHP extensions.";
        exit(-1);
    }
    // call the function that will return all detected templates
    $doSkip = TRUE;
    $arrTemplates = detectTemplates($sourceDir, $detectorDbFileName, $doSkip);
    if ($doSkip) {
        echo "Detector " . basename(__FILE__, '.php') . " cannot detect template files for {$sourceDir} ... skipping\n";
    } else {
        if ($outputDbFileName) {
            // now send the detected templates to either STDOUT or store in the
            // sqlite DB
            $pdo = Zend_Db::factory('Pdo_Sqlite', array("dbname" => $outputDbFileName));
            $templateFileTable = new Triumph_TemplateFileTagTable($pdo);
            $templateFileTable->saveTemplateFiles($arrTemplates, $sourceDir);
            echo "Template file detection complete, written to {$outputDbFileName}\n";
        } else {
            if (!empty($arrTemplates)) {
                echo str_pad("Template File", 60) . str_pad("Variables", 90) . "\n";
                foreach ($arrTemplates as $template) {
                    echo str_pad($template->fullPath, 60);
                    echo str_pad(join(',', $template->variables), 90);
                    echo "\n";
                }
            } else {
                echo "No template files were detected for {$sourceDir}\n";
            }
        }
    }
}
Exemplo n.º 20
0
set_include_path(implode(PATH_SEPARATOR, array(realpath(APPLICATION_PATH . '/../library'), get_include_path())));
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
$optsConfig = array_merge($optsConfig, array('app_env=s' => 'Parametr jest wymaganay i może przyjmować jedynie nazwy sekcji obecnych w pliku configuracyjnym application/configs/application.ini'));
//$args = $_SERVER['argv'];
//var_dump($optsConfig);
try {
    $opts = new Zend_Console_Getopt($optsConfig);
    $opts->setOptions(array('ignoreCase' => true, 'dashDash' => false));
    $opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
    echo "\n\n" . $e->getMessage() . "\n\n" . $e->getUsageMessage() . "\n\n";
    exit;
}
if (isset($opts->h)) {
    echo "\n\n" . $opts->getUsageMessage() . "\n\n";
    exit;
}
if (isset($opts->app_env)) {
    defined('APPLICATION_ENV') || define('APPLICATION_ENV', $opts->app_env);
} else {
    echo "\n\nParametr app_env jest wymagany!";
    echo "\n\n" . $opts->getUsageMessage() . "\n\n";
    exit;
}
/** Zend_Application */
require_once 'Zend/Application.php';
// Create application, bootstrap, and run
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
Base_Controller_Action_Helper_Currentip::$_unitTestEnabled = true;
$application->bootstrap();
/**
 * path to tine 2.0 checkout
 */
$tine20path = dirname(dirname(dirname(__FILE__)));
/**
 * options
 */
try {
    $opts = new Zend_Console_Getopt(array('help|h' => 'Display this help Message', 'verbose|v' => 'Output messages', 'host=s' => 'hostname/ip of Fritzbox (defaults to fritz.box)'));
    $opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
    fwrite(STDOUT, $e->getUsageMessage());
    exit(1);
}
if ($opts->h) {
    fwrite(STDOUT, $opts->getUsageMessage());
    exit;
}
$fritzbox = $opts->host ? $opts->host : 'fritz.box';
if ($opts->v) {
    fwrite(STDOUT, "Trying to connect to Fritzbox: '{$fritzbox}'\n");
}
$fp = @fsockopen("tcp://{$fritzbox}", 1012, $errno, $errstr, 5);
if (!$fp) {
    fwrite(STDERR, "Could not open connection to Fritzbox '{$fritzbox}': {$errstr} (error {$errno})\n");
    exit(1);
}
if ($opts->v) {
    fwrite(STDOUT, "Successfully connected to Fritzbox: '{$fritzbox}'\n");
}
stream_set_timeout($fp, 60);
Exemplo n.º 22
0
 /**
  * Test an action
  *
  * This is the test action method. It test a specific action.
  *
  * @return void
  */
 public function testAction()
 {
     $this->_helper->viewRenderer->setViewSuffix('txt');
     // The options we are accepting for adding
     $options = new Zend_Console_Getopt(array('name|n=s' => 'Name of the action to call.', 'parameters|p=s' => 'Paramters to use. For example var1=val1&var2=val2', 'format|f=s' => 'Format to return. Defaults to XML.', 'method|m=s' => 'Method to use. Defaults to GET.', 'email|e=s' => 'Email or username to use.', 'secretkey|sk=s' => 'Secret key associated with email passed.', 'domain|d=s' => 'Domain to use, if not included will use default', 'query-uri|u=s' => 'Query uri to use. For example /testing/1', 'https|h' => 'Use https.'));
     try {
         $options->parse();
     } catch (Zend_Console_Getopt_Exception $e) {
         $this->view->message = $e->getUsageMessage();
         return;
     }
     if ($options->name == '') {
         $this->view->message = $options->getUsageMessage();
         return;
     }
     $confModel = new Default_Model_Configuration();
     if (!$confModel->getKey('api_url')) {
         $this->view->message = 'Remember you can set the default API domain name in your admin configuration.' . PHP_EOL;
     }
     if (!class_exists('HttpRequest')) {
         $this->view->message = 'HttpRequest class was not found the pecl_http (http://pecl.php.net/package/pecl_http) package is required to use the tester.' . PHP_EOL;
         return;
     }
     $action_name = $options->name;
     $params = $options->parameters;
     $format = $options->format;
     $method = $options->method;
     $email = $options->email;
     $password = $options->secretkey;
     $url = $options->domain;
     $ssl = $options->https;
     $query_uri = $options->getOption('query-uri');
     if ($url == '') {
         $url = $confModel->getKey('api_url');
     }
     if ($query_uri == '') {
         $actionModel = new Default_Model_Action();
         $actions = $actionModel->getAll();
         foreach ($actions as $action_details) {
             if ($action_details['name'] == $action_name) {
                 $query_uri = $action_details['route'];
             }
         }
     }
     $newMethod = HTTP_METH_GET;
     switch (strtolower($method)) {
         case 'get':
             $newMethod = HTTP_METH_GET;
             break;
         case 'post':
             $newMethod = HTTP_METH_POST;
             break;
         case 'put':
             $newMethod = HTTP_METH_PUT;
             break;
         case 'delete':
             $newMethod = HTTP_METH_DELETE;
             break;
         case 'head':
             $newMethod = HTTP_METH_HEAD;
             break;
     }
     $request_url = 'http' . ($ssl !== null ? 's' : '') . '://' . $url . '/' . $query_uri . '.' . strtolower($format);
     $httpOptions = array();
     if ($email && $password) {
         $httpOptions = array('headers' => array('Accept' => '*/*'), 'httpauth' => $email . ':' . $password, 'httpauthtype' => HTTP_AUTH_DIGEST);
     }
     $request = new HttpRequest($request_url, $newMethod, $httpOptions);
     if ("POST" == strtoupper($method)) {
         $request->setBody($params);
     } else {
         $request->setQueryData($params);
     }
     $res = $request->send();
     $responseInfo = $request->getResponseInfo();
     $this->view->request_url = $responseInfo['effective_url'];
     $this->view->response_header = $this->collapseHeaders($res->getHeaders());
     $this->view->content = $res->getBody();
     $this->view->status = $res->getResponseCode();
     $this->view->method = isset($method) ? strtoupper($method) : 'GET';
     $this->view->request_post_fields = $newMethod == HTTP_METH_POST ? $params : '';
 }
Exemplo n.º 23
0
 /**
  * Delete an error
  *
  * This is the delete error method. It allows you to delete an error.
  *
  * @return void
  */
 public function deleteAction()
 {
     $this->_helper->viewRenderer->setViewSuffix('txt');
     // The options we are accepting for deleting
     $options = new Zend_Console_Getopt(array('name|n=s' => $this->tr->_('NAME')));
     try {
         $options->parse();
     } catch (Zend_Console_Getopt_Exception $e) {
         $this->view->message = $e->getUsageMessage();
         return;
     }
     if ($options->name == '') {
         $this->view->message = $options->getUsageMessage();
         return;
     }
     $error_name = strtoupper($options->name);
     $model = new Default_Model_Error();
     $tempErrors = $model->getAll();
     $error_id = null;
     foreach ($tempErrors as $key => $value) {
         if ($error_name == strtoupper($value['name'])) {
             $error_id = $value['hash'];
             break;
         }
     }
     if (!$error_id) {
         $this->view->message = $this->tr->_('COULD_NOT_DELETE_ERROR') . ': ' . $error_name . '. ' . $this->tr->_('COULD_NOT_FIND_MATCH') . '.' . PHP_EOL;
         return;
     }
     try {
         $model->delete($error_id);
         $this->view->message = $this->tr->_('SUCCESS_DELETE_ERROR') . ': ' . $error_name . PHP_EOL;
     } catch (RuntimeException $e) {
         $this->view->message = $this->tr->_('ERROR_DELETING_ERROR') . ': ' . $error_name . '. ' . $e->getMessage() . PHP_EOL;
     }
 }
Exemplo n.º 24
0
 function launch($args = null)
 {
     $args = $args ? $args : $_SERVER["argv"];
     $getoptRules = array();
     $jobClassnames = glob("{$this->jobDir}/*{$this->clsSuffix}.php");
     $proceed = 0;
     if ($jobClassnames) {
         //$this->logger->debug("Found " . count($jobClassnames) . " job classes");
         foreach ($jobClassnames as $filename) {
             $basename = basename($filename);
             if (in_array($basename[0], array("_", "."))) {
                 continue;
             }
             $fname = pathinfo($filename, PATHINFO_FILENAME);
             $className = ($this->clsNamespace ? "{$this->clsNamespace}_" : "") . $fname;
             require_once "{$this->jobDir}/{$basename}";
             if (class_exists($className, false)) {
                 if (method_exists($className, "getConfig")) {
                     // Extract job name
                     $jobName = str_replace($this->clsSuffix, "", $fname);
                     // Call static getConfig from job class
                     $jobConfig = $this->computeConfig($className);
                     // Add job to cron CLI options
                     $getoptRules[$jobName] = $jobConfig["description"];
                     // Process job own CLI options
                     if ($jobConfig["getoptRules"]) {
                         foreach ($jobConfig["getoptRules"] as $rule => $description) {
                             // If such rule already exists, append cronjob name to With --JobName
                             $description = key_exists($rule, $getoptRules) ? preg_replace('/\\)$/', ", --{$jobName})", $getoptRules[$rule]) : "{$description} (With --{$jobName})";
                             $getoptRules[$rule] = $description;
                         }
                     }
                     $proceed++;
                 } else {
                     $this->logger->error("Class {$className} has no static method getConfig");
                 }
             } else {
                 $this->logger->error("No {$className} was found in {$filename}");
             }
         }
     }
     if (!$jobClassnames || !$proceed) {
         throw new Scalr_System_Cronjob_Exception(sprintf("No job classes found in '%s'", $this->jobDir));
     }
     $getoptRules["help"] = "Print this help";
     // Parse command line options
     $getopt = new Zend_Console_Getopt($getoptRules, $args);
     try {
         $getopt->parse();
     } catch (Zend_Console_Getopt_Exception $e) {
         print "{$e->getMessage()}\n\n";
         die($getopt->getUsageMessage());
     }
     // Instantiate cronjob class
     $cronjobName = $this->oldSyntax ? substr($args[1], 2) : $args[count($args) - 1];
     if (!$cronjobName || $getopt->getOption("help")) {
         die($getopt->getUsageMessage());
     }
     $filename = "{$this->jobDir}/{$cronjobName}{$this->clsSuffix}.php";
     $jobClassName = ($this->clsNamespace ? "{$this->clsNamespace}_" : "") . pathinfo($filename, PATHINFO_FILENAME);
     require_once $filename;
     // Compute cronjob configuration
     $jobConfig = $this->computeConfig($jobClassName);
     $jobConfig["jobName"] = $cronjobName;
     if (is_subclass_of($jobClassName, "Scalr_System_Cronjob_MultiProcess_Worker")) {
         $jobConfig["worker"] = new $jobClassName();
         if ($jobConfig["distributed"]) {
             $jobClassName = "Scalr_System_Cronjob_Distributed";
         } else {
             $jobClassName = "Scalr_System_Cronjob_MultiProcess";
         }
     }
     $this->logger->info("Starting {$cronjobName} ...");
     $cronjob = new $jobClassName($jobConfig);
     $cronjob->run(array("getopt" => $getopt));
 }
/**
 * This function will look at the given program arguments and will validate them.
 * If the required arguments have been passed then it will call the Tag detector function,
 * otherwise it will stop the program.
 * This function is called at the end of this script (see last line of this file).
 * The help text below describes the arguments that are needed.
 */
function parseArgs()
{
    $rules = array('sourceDir|d=s' => 'Required. The base directory that the project resides in', 'resourceDbFileName|i=s' => 'Required. SQLite file that contains the project\'s files, classes, and methods. This file is created by ' . 'Triumph; Triumph performs INSERTs as it indexes a project.', 'outputDbFileName|o-s' => 'Optional. If given, the output will be written to the given file. If not given, output goes to STDOUT.', 'help|h' => 'This help message');
    $opts = new Zend_Console_Getopt($rules);
    // trim any quotes
    $sourceDir = trim($opts->getOption('sourceDir'), " \r\n\t'\"");
    $resourceDbFileName = trim($opts->getOption('resourceDbFileName'), " \r\n\t'\"");
    $outputDbFileName = trim($opts->getOption('outputDbFileName'), " \r\n\t'\"");
    $help = trim($opts->getOption('help'), " \r\n\t'\"");
    if ($help) {
        $helpMessage = <<<EOF
The goal of this script is to discover all of the 'dynamic' tags for any PHP projects that use the
CodeIgniter framework. In a nutshell, Triumph cannot provide Code completion for calling the
core CodeIgniter classes within a controller (ie "{$this->input}" will not trigger code completion").
This script will add he CI core objects and libraries to the Triumph tag cache so that 
Triumph can know about them during code completion. It will also
detect any user-created libraries as well. This script.
will be called via a command line; it is a normal command line script.

This script is part of Triumph's Tag Detection feature; it enables the editor to have a 
more useful list when performing code completion. More
info can be about Triumph's Tag detector feature can be found at 
http://docs.triumph4php.com/tag-detectors/

When a required argument is invalid or missing, the program will exit with an error code (-1)

EOF;
        echo $helpMessage;
        echo "\n";
        echo $opts->getUsageMessage();
        exit(-1);
    }
    if (!$sourceDir) {
        echo "Missing argument: --sourceDir. See --help for details.\n";
        exit(-1);
    }
    if (!is_dir($sourceDir)) {
        echo "sourceDir is not a valid directory. Is \"{$sourceDir}\" a directory? Is it readable? \n";
        exit(-1);
    }
    if (!$resourceDbFileName) {
        echo "Missing argument: --resourceDbFileName. See --help for details.\n";
        exit(-1);
    }
    if (!extension_loaded('pdo_sqlite') || !extension_loaded('PDO')) {
        echo "The script " . basename(__FILE__) . " requires the PDO and pdo_sqlite PHP extensions.";
        exit(-1);
    }
    // call the function that will return all detected URLs
    $doSkip = TRUE;
    $arrTags = detectTags($sourceDir, $resourceDbFileName, $doSkip);
    if ($doSkip) {
        echo "Detector " . basename(__FILE__, '.php') . " cannot detect tags for  {$sourceDir} ... skipping\n";
    } else {
        if ($outputDbFileName) {
            // now send the detected URLs to either STDOUT or store in the
            // sqlite DB
            $pdo = Zend_Db::factory('Pdo_Sqlite', array("dbname" => $outputDbFileName));
            $resourceTable = new Triumph_DetectedTagTable($pdo);
            $resourceTable->saveTags($arrTags, $sourceDir);
            echo "Tag detection complete, written to {$outputDbFileName}\n";
        } else {
            if (!empty($arrTags)) {
                echo str_pad("Type", 10) . str_pad("Class", 25) . str_pad("Member", 25) . str_pad("Return Type", 20) . "\n";
                foreach ($arrTags as $tag) {
                    echo str_pad(Triumph_DetectedTag::typeString($tag->type), 10);
                    echo str_pad($tag->className, 25);
                    echo str_pad($tag->identifier, 25);
                    echo str_pad($tag->returnType, 25);
                    echo "\n";
                }
            } else {
                echo "No tags were detected for {$sourceDir}\n";
            }
        }
    }
}
Exemplo n.º 26
0
 /**
  * Parses the comment line.
  */
 private function _parseCommandLine()
 {
     try {
         $opts = new Zend_Console_Getopt(Daiquiri_Init::$_commandline_options);
         $opts->parse();
     } catch (Zend_Console_Getopt_Exception $e) {
         exit($e->getMessage() . "\n\n" . $e->getUsageMessage());
     }
     foreach (array_keys(Daiquiri_Init::$_commandline_options) as $key) {
         $arr = explode('|', $key);
         if (isset($opts->{$arr}[0])) {
             $this->_opts[] = $arr[1];
         }
     }
     // show help message
     if (isset($opts->h) || count($this->_opts) == 0) {
         echo $opts->getUsageMessage();
         exit;
     }
 }
Exemplo n.º 27
0
try {
    $application->bootstrap();
    $bootstrap = $application->getBootstrap();
    $bootstrap->bootstrap('frontController');
} catch (Exception $e) {
    die(print_r($e, true));
}
try {
    $opts = new Zend_Console_Getopt(array('help|h' => 'Displays usage information.', 'action|a=s' => 'Action to perform in format of module.controller.action', 'verbose|v' => 'Verbose messages will be dumped to the default output.', 'debug|d' => 'Enables debug mode.', 'copyright|c' => 'Display copyright information.'));
    $opts->parse();
} catch (Zend_Console_Getopt_Exception $e) {
    exit($e->getMessage() . "\n\n" . $e->getUsageMessage());
}
if (isset($opts->h)) {
    echo SCRIPT_NAME . "\n" . SCRIPT_COPY . "\n\n";
    echo $opts->getUsageMessage();
    exit;
}
if (isset($opts->c)) {
    echo SCRIPT_NAME . "\n" . SCRIPT_COPY . "\n\n";
    echo "Information in this file is strictly confidential and the property of\n" . "Open Source Solutions Limited and may not be extracted or distributed,\n" . "in whole or in part, for any purpose whatsoever, without the express\n" . "written consent from Open Source Solutions Limited.\n\n";
    exit;
}
if (isset($opts->a)) {
    try {
        $reqRoute = array_reverse(explode('.', $opts->a));
        @(list($action, $controller, $module) = $reqRoute);
        if ($action != '' && $controller == '') {
            $controller = $action;
            $action = 'index';
        }
Exemplo n.º 28
0
<?php

/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */
require_once __DIR__ . '/bootstrap.php';
use Magento\Tools\I18n\ServiceLocator;
try {
    $console = new \Zend_Console_Getopt(['directory|d=s' => 'Path to a directory to parse', 'output-file|o=s' => 'Path (with filename) to output file, ' . 'by default output the results into standard output stream', 'magento|m-s' => 'Indicates whether the specified "directory" path is a Magento root directory,' . ' "no" by default']);
    $console->parse();
    if (!count($console->getOptions())) {
        throw new \Zend_Console_Getopt_Exception('Required parameters are missed, please see usage description', $console->getUsageMessage());
    }
    $directory = $console->getOption('directory');
    if (empty($directory)) {
        throw new \Zend_Console_Getopt_Exception('Directory is a required parameter.', $console->getUsageMessage());
    }
    $outputFilename = $console->getOption('output-file') ?: null;
    $isMagento = in_array($console->getOption('magento'), ['y', 'yes', 'Y', 'Yes', 'YES', '1']);
    $generator = ServiceLocator::getDictionaryGenerator();
    $generator->generate($directory, $outputFilename, $isMagento);
    fwrite(STDOUT, "\nDictionary successfully processed.\n");
} catch (\Zend_Console_Getopt_Exception $e) {
    fwrite(STDERR, $e->getMessage() . "\n\n" . $e->getUsageMessage() . "\n");
    exit(1);
} catch (\Exception $e) {
    fwrite(STDERR, $e->getMessage() . "\n");
    exit(1);
}
Exemplo n.º 29
0
defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../core/application'));
set_include_path(implode(PATH_SEPARATOR, array(APPLICATION_PATH . '/../library', get_include_path())));
require_once 'Zend/Loader/Autoloader.php';
Zend_Loader_Autoloader::getInstance();
// Define some CLI options
$getopt = new Zend_Console_Getopt(array('withbuffer|b' => 'Load database with buffer data', 'withdata|w' => 'Load database with sample data', 'withdevs|d' => 'Load database with dev settings', 'env|e-s' => 'Application environment for which to create database (defaults to development)', 'help|h' => 'Help -- usage message'));
try {
    $getopt->parse();
} catch (Zend_Console_Getopt_Exception $e) {
    // Bad options passed: report usage
    echo $e->getUsageMessage();
    return false;
}
// If help requested, report usage message
if ($getopt->getOption('h')) {
    echo $getopt->getUsageMessage();
    return true;
}
// Initialize values based on presence or absence of CLI options
$withData = $getopt->getOption('w');
$withBuffer = $getopt->getOption('b');
$withDevs = $getopt->getOption('d');
$env = $getopt->getOption('e');
defined('APPLICATION_ENV') || define('APPLICATION_ENV', null === $env ? 'development' : $env);
// Initialize Zend_Application
$application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
// Initialize and retrieve DB resource
$bootstrap = $application->getBootstrap();
$bootstrap->bootstrap('db');
$dbAdapter = $bootstrap->getResource('db');
// let the user know whats going on (we are actually creating a
Exemplo n.º 30
0
 /**
  * Adds a nice little application description to the top of the usage menu
  * @return string
  */
 public function getUsageMessage()
 {
     $str = "ec2-manage-snapshots prunes old volume snapshots from " . "your Amazon EC2 account\n\n";
     return $str . parent::getUsageMessage() . "\n";
 }