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


PHP Cli::getOption方法代码示例

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


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

示例1: dir

}
$dir = dir($baseDir);
$currentVersionFile = $baseDir . DIRECTORY_SEPARATOR . 'current';
// this block executes the actual statements that were loaded from
// the schema file.
try {
    // let the user know whats going on (we are actually creating a
    // database here)
    if ('testing' != APPLICATION_ENV) {
        echo 'Writing Database for environment <' . APPLICATION_ENV . '> in (control-c to cancel): ' . PHP_EOL;
        for ($x = 3; $x > 0; $x--) {
            echo $x . "\r";
            sleep(1);
        }
    }
    $from = $cli->getOption('f');
    if (!$from) {
        $item = $db->config->findOne(array('_id' => 'version'));
        if ($item && isset($item['version'])) {
            $from = $item['version'];
        }
    }
    if (!$from) {
        if (file_exists($currentVersionFile)) {
            $from = file_get_contents($currentVersionFile);
        } else {
            $from = "0rev0";
        }
    }
    list($fromVer, $fromRev) = explode('rev', $from, 2);
    echo "Current version: " . $fromVer . "rev" . $fromRev . "\n";
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:31,代码来源:update.php

示例2: realpath

#!/usr/bin/env php
<?php 
/**
 * Script for remove user session
 */
require_once realpath(dirname(__FILE__) . '/lib/Cli.php');
$cli = new Cli(array('userName|u=s' => 'User name of the session to delete ', 'debugMode|d-i' => 'Use 1 to enable debug mode (defaults to 0) '));
/**
 * @var MongoCollection
 */
$db = $cli->getResource('mongo');
$userName = $cli->getOption('u');
$debug = $cli->getOption('d');
try {
    if ($cli->getOption('u') === null) {
        throw new Exception("The 'userName' parameter is required");
    }
    if ($debug == 1) {
        $list = $db->session->find();
        foreach ($list as $session) {
            $s = $session['rawData']['Zend_Auth']['storage']['username'];
            print_r($s . "\n");
        }
        echo "\n" . $db->session->count() . "\n";
    }
    $count = $db->session->count() . "\n";
    $remove = $db->session->remove(array("rawData.Zend_Auth.storage.username" => "{$userName}"));
    $count_after_remove = $db->session->count() . "\n";
    if ($count > $count_after_remove) {
        echo "Removed active session for '{$userName}' user. \n";
    } else {
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:31,代码来源:removeUserSession.php

示例3: Cli

#!/usr/bin/env php
<?php 
/**
 * Script for creating and loading database
 * Execute "php load.oracle.php --help" for help
 */
// Initialize the application path and autoloading
require_once 'lib/Cli.php';
$cli = new Cli(array('drop|d' => 'Drop database and data', 'file|f=s' => 'Load file'), false);
try {
    /**
     * @var MongoCollection
     */
    if ($cli->getOption('e') === null) {
        throw new Exception('Need environment param');
    }
    global $db;
    global $drop;
    $db = $cli->getResource('mongo');
    $cli->getResource('cachemanager');
    // let the user know whats going on (we are actually creating a
    // database here)
    if ('testing' != APPLICATION_ENV) {
        echo 'Writing Database for environment <' . APPLICATION_ENV . '> in (control-c to cancel): ' . PHP_EOL;
        for ($x = 3; $x > 0; $x--) {
            echo $x . "\r";
            sleep(1);
        }
    }
    $env = $cli->getOption('e');
    $yamlFile = $cli->getOption('f');
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:31,代码来源:load.mongodb.php

示例4: Cli

#!/usr/bin/env php
<?php 
use Application\Service\OrgService;
use Application\Service\UserService;
use Application\Model\Organization\OrgCustomerModel;
use Application\Model\Validate\Organization\OrgParamMatchRegex;
/**
 * Script for delete Orgs
 */
require_once 'lib/Cli.php';
$cli = new Cli(array('filter|f-s' => 'organization key=value params to filter-out to delete several filters can be added in the form [key=value&key=value,...]', 'type|t-s' => 'organization type to delete'), false);
try {
    if ($cli->getOption('e') === null) {
        throw new Exception('Need environment param');
    }
    if ($cli->getOption('f') === null) {
        throw new Exception('Need organization name param');
    }
    //service instantation;
    $orgService = OrgService::getInstance();
    $orgFilterString = $cli->getOption('f');
    //this option can be included on filters too
    $orgType = $cli->getOption('t') ?: 'customer';
    parse_str($orgFilterString, $params);
    $params += array('type' => $orgType);
    /**
     * @var $filterList App_ListFilter
     */
    $filterList = $orgService->buildFilterList($params);
    if (!$filterList->filterCount()) {
        foreach ($params as $key => $value) {
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:31,代码来源:deleteOrgsWithFilters.php

示例5: realpath

#!/usr/bin/env php
<?php 
/**
 * Script to upgrade tariff templates
 */
require_once realpath(dirname(__FILE__) . '/lib/Cli.php');
$cli = new Cli(array('file|f=s' => 'Path to zone upgrading file. REQUIRED', 'zoneNamesfile|n=s' => 'Path to zone names file.', 'orgId|o=s' => 'Organization where upgrade tariff templates. If it is not defined it will try to use the name of file as orgId', 'separator|s=s' => "Separator of file data. Defautl \"\t\" [TAB]"));
try {
    $logs = array();
    App_MigrationTool_TemplatesTo20_ServiceTariffUtils::performUpgrade($cli->getOption('o'), $cli->getOption('f'), $cli->getOption('n'), $cli->getOption('s'), $logs);
    foreach ($logs as $line) {
        echo $line . "\n";
    }
} catch (Exception $e) {
    echo 'AN ERROR HAS OCCURRED:' . PHP_EOL;
    echo $e->getMessage() . PHP_EOL;
    foreach ($logs as $line) {
        echo $line . "\n";
    }
    exit(1);
}
// generally speaking, this script will be run from the command line
exit(0);
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:23,代码来源:upgradeTariffTemplateByOrgId-2.0.php

示例6: acl2Json

#!/usr/bin/env php
<?php 
/**
 * Script
 */
require_once realpath(dirname(__FILE__) . '/lib/Cli.php');
$cli = new Cli(array('namespace|n=s' => "Update a namespace. [REQUIRED]", 'path|p-s' => "Define acl files base path. Default: /data/acl/build", 'no-resources|r' => "Avoid backup resources document."));
define("DEFAULT_ACL_BASEPATH", realpath(APPLICATION_PATH . '/../data/acl/build'));
try {
    /**
     * @var MongoCollection
     */
    $db = $cli->getResource('mongo');
    $env = $cli->getOption('e');
    $basepath = rtrim($cli->getOption('p') ?: DEFAULT_ACL_BASEPATH, DIRECTORY_SEPARATOR);
    $namespace = $cli->getOption('n');
    if (!($namespace = $cli->getOption('n'))) {
        echo "Namespace is requiered";
        exit(1);
    }
    $noResources = $cli->getOption('r') ? true : false;
    acl2Json($db, $namespace, $basepath, $noResources);
    //create JSON file from acl_portal collection
} catch (Exception $e) {
    echo "Error:\n";
    echo get_class($e) . ": " . $e->getMessage() . "\n";
    echo $e->getTraceAsString();
    exit(100);
}
function acl2Json($db, $ns, $basepath, $noResources = False)
{
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:31,代码来源:aclBackup.php

示例7: realpath

#!/usr/bin/env php
<?php 
/**
 * Script for delete test org by the name
 */
require_once realpath(dirname(__FILE__) . '/lib/Cli.php');
$cli = new Cli(array('field|f-s' => 'db field (name  by default)', 'type|t-s' => 'Organization name for delete (no organization for delete  by default)', 'drop|d' => 'Drop database and data'));
// Initialize values based on presence or absence of CLI options
$field = $cli->getOption('f');
$name = $cli->getOption('t');
try {
    if ($cli->getOption('t') === null) {
        throw new Exception('Need organization name param');
    }
    if ($cli->getOption('f') === null) {
        $field = 'name';
    }
    /**
     * @var MongoCollection
     */
    $db = $cli->getResource('mongo');
    $count = $db->org_mock->count();
    $res = $db->org_mock->remove(array("{$field}" => "{$name}"));
    echo "removing org " . $name . " \n";
    $dcount = $db->org_mock->count();
    if ($count == $dcount) {
        echo "not exists an organization with " . $field . " = " . $name . " \n";
    } else {
        echo "removed Organitzation with " . $field . " = " . $name . " \n";
        $cacheManager = $cli->getResource('cachemanager');
        $cache = $cacheManager->getCache('memcached');
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:31,代码来源:deleteTestOrgByName.php

示例8: realpath

#!/usr/bin/env php
<?php 
use Core\Service\Transport\PopboxService;
use Core\Model\WatcherModel;
use Core\Service\WatcherService;
use Core\Model\EventModel;
use Application\Exceptions\InvalidArgumentException;
require_once realpath(dirname(__FILE__) . '/lib/Cli.php');
/**
 * Script
 */
$cli = new Cli(array('file|f-s' => "Json file for event.", 'cacheId|c-s' => "CacheId of event.", 'scopes|s=s' => "Coma separated scopes", 'low|l' => "Mark as priority low. If it isn't send it use high priority."));
try {
    if ($file = $cli->getOption('f')) {
        if (!file_exists($file)) {
            throw new InvalidArgumentException("File doesn't exist");
        }
        $json = file_get_contents($file);
        unlink($file);
        $data = Zend_Json::decode($json);
        $event = new EventModel($data);
    } else {
        if (!($cacheId = $cli->getOption('c')) || !($event = \App::cache()->load($cacheId))) {
            throw new InvalidArgumentException("File or cacheId valid is required");
        }
    }
    $scopes = explode(',', $cli->getOption('s'));
    $priority = $cli->getOption('l') ? WatcherModel::PRIORITY_HIGH : WatcherModel::PRIORITY_LOW;
    PopboxService::getInstance()->sendNotification($scopes, $event, $priority);
    //create JSON file from acl_portal collection
} catch (Exception $e) {
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:31,代码来源:eventSender.php

示例9: realpath

<?php 
/**
 * Script for remove user session
 */
require_once realpath(dirname(__FILE__) . '/lib/Cli.php');
$cli = new Cli(array('drop|d' => "Remove current data."), false);
if ($cli->getApplication() == null) {
    exit(1);
}
/**
 * @var MongoCollection
 */
$db = $cli->getResource('mongo');
define("DEFAULT_ACL_BASEPATH", realpath(APPLICATION_PATH . '/../data/acl'));
try {
    $env = $cli->getOption('e');
    $drop = $cli->getOption('d') ? true : false;
    $f = file_get_contents(DEFAULT_ACL_BASEPATH . "/build/acl_out.json", 'r');
    if (!$f) {
        throw new Exception("Error to load file \n");
    }
    //decoding json file
    $json_a = Zend_Json_Decoder::decode($f);
    if ($drop) {
        echo "\nDrop acl_portal from " . $env . " env \n";
        $db->acl_portal->drop();
    }
    foreach ($json_a as $element) {
        $db->acl_portal->insert($element);
    }
    \App::cache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('Namespace'));
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:31,代码来源:json2mongo.php

示例10: Cli

#!/usr/bin/env php
<?php 
use Application\Service\OrgService;
use Application\Service\UserService;
use Application\Model\Organization\OrgCustomerModel;
/**
 * Script for delete Orgs
 */
require_once 'lib/Cli.php';
$cli = new Cli(array('orgId|o=s' => 'Org id to delete '), false);
try {
    if ($cli->getOption('e') === null) {
        throw new Exception('Need environment param');
    }
    if ($cli->getOption('o') === null) {
        throw new Exception('Need organization id param');
    }
    $orgId = $cli->getOption('o');
    $orgService = OrgService::getInstance();
    //removing org
    Application\Model\Mapper\ProtoAbstractMapper::$organizationId = $orgId;
    $org = $orgService->load($orgId);
    if ($org != null) {
        App::getOrgUserLogged($org);
        try {
            $orgService->delete($org->getId());
            echo "The organization with Id {$orgId} has been deleted \n";
        } catch (Exception $e) {
            echo 'AN ERROR HAS OCCURRED:' . PHP_EOL;
            echo $e->getMessage() . PHP_EOL;
            \App::log()->warn($e);
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:31,代码来源:deleteOrg.php

示例11: realpath

#!/usr/bin/env php
<?php 
use Application\Exceptions\InvalidArgumentException;
require_once realpath(dirname(__FILE__) . '/lib/Cli.php');
define("DEFAULT_ACL_BASEPATH", realpath(APPLICATION_PATH . '/../data/acl'));
/**
 * Script
 */
$cli = new Cli(array('namespace|n-s' => "Update a namespace. Default: all", 'drop|d' => "Remove current data.", 'path|p-s' => "Define acl files base path. Default: " . DEFAULT_ACL_BASEPATH, 'format|f-s' => "Acl format: yaml, oldIni, ini or json. Default: yaml" . DEFAULT_ACL_BASEPATH, 'extra-prefix|x-s' => "Define prefix for extra files. Default: empty."));
try {
    /**
     * @var MongoCollection
     */
    $db = $cli->getResource('mongo');
    $env = $cli->getOption('e');
    $drop = $cli->getOption('d') ? true : false;
    $basepath = rtrim($cli->getOption('p') ?: DEFAULT_ACL_BASEPATH, DIRECTORY_SEPARATOR);
    $extraSubdir = $cli->getOption('x') ?: '';
    $format = $cli->getOption('f') ?: 'yaml';
    $namespaces = findNamespaces($basepath, $extraSubdir, $format);
    if (!($namespace = $cli->getOption('n')) || $namespace == 'all') {
        foreach ($namespaces as $ns => $files) {
            loadAcl($files, $ns, $format, $drop);
        }
    } else {
        if (isset($namespaces[$namespace])) {
            loadAcl($namespaces[$namespace], $namespace, $format, $drop);
        } else {
            echo "Namespace {$namespace} does not exist";
        }
    }
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:31,代码来源:aclLoader.php

示例12: realpath

#!/usr/bin/env php
<?php 
use Core\Service\WatcherService;
use Core\Model\EventModel;
use Application\Exceptions\InvalidArgumentException;
require_once realpath(dirname(__FILE__) . '/lib/Cli.php');
define("DEFAULT_ACL_BASEPATH", realpath(APPLICATION_PATH . '/../data/acl'));
/**
 * Script
 */
$cli = new Cli(array('file|f-s' => "Json file for event.", 'cacheId|c-s' => "CacheId of event."));
try {
    if ($file = $cli->getOption('f')) {
        if (!file_exists($file)) {
            throw new InvalidArgumentException("File doesn't exist");
        }
        $json = file_get_contents($file);
        unlink($file);
        $data = Zend_Json::decode($json);
        $event = new EventModel($data);
    } else {
        if (!($cacheId = $cli->getOption('c')) || !($event = \App::cache()->load($cacheId))) {
            throw new InvalidArgumentException("File or cacheId valid is required");
        }
    }
    WatcherService::getInstance()->publishEventInternal($event);
    //create JSON file from acl_portal collection
} catch (Exception $e) {
    echo "Error:\n";
    echo get_class($e) . ": " . $e->getMessage() . "\n";
    echo $e->getTraceAsString();
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:31,代码来源:eventPublisher.php

示例13: realpath

#!/usr/bin/env php
<?php 
/**
 * Script
 */
require_once realpath(dirname(__FILE__) . '/lib/Cli.php');
$cli = new Cli(array('namespace|n-s' => "Update a namespace. Default: all", 'path|p-s' => "Define acl files base path. Default: /data/acl/build", 'drop|d' => "Remove current data."));
define("DEFAULT_ACL_BASEPATH", realpath(APPLICATION_PATH . '/../data/acl/build'));
try {
    /**
     * @var MongoCollection
     */
    $db = $cli->getResource('mongo');
    $env = $cli->getOption('e');
    $basepath = rtrim($cli->getOption('p') ?: DEFAULT_ACL_BASEPATH, DIRECTORY_SEPARATOR);
    $namespace = $cli->getOption('n');
    $drop = $cli->getOption('d') ? true : false;
    $namespaces = getAclNamespaces($basepath);
    if (!($namespace = $cli->getOption('n')) || $namespace == 'all') {
        foreach ($namespaces as $ns => $file) {
            json2Acl($db, $ns, $file, $drop);
        }
    } else {
        if (isset($namespaces[$namespace])) {
            json2Acl($db, $namespace, $namespaces[$namespace], $drop);
        } else {
            echo "Namespace {$namespace} does not exist";
        }
    }
    //create JSON file from acl_portal collection
} catch (Exception $e) {
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:31,代码来源:aclRestore.php

示例14: realpath

#!/usr/bin/env php
<?php 
/**
 * Script
 */
require_once realpath(dirname(__FILE__) . '/lib/Cli.php');
$cli = new Cli(array('namespace|n-s' => "Update a namespace. Default: all", 'drop|d' => "Remove current data.", 'path|p-s' => "Define acl files base path. Default: /data/acl"));
define("DEFAULT_ACL_BASEPATH", realpath(APPLICATION_PATH . '/../data/acl'));
try {
    /**
     * @var MongoCollection
     */
    $db = $cli->getResource('mongo');
    $env = $cli->getOption('e');
    $drop = $cli->getOption('d') ? true : false;
    $basepath = $cli->getOption('p') ?: DEFAULT_ACL_BASEPATH;
    $namespaces = getAclNamespaces($basepath);
    if (!($namespace = $cli->getOption('n')) || $namespace == 'all') {
        if ($drop) {
            foreach ($namespaces as $ns => $file) {
                \App::cache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('Namespace'));
                dropNamespace($ns);
            }
        }
        foreach ($namespaces as $ns => $file) {
            \App::cache()->clean(Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array('Namespace'));
            updateNamespace($ns, $file);
        }
    } else {
        if (isset($namespaces[$namespace])) {
            if ($drop) {
开发者ID:SandeepUmredkar,项目名称:PortalSMIP,代码行数:31,代码来源:acl2mongo.php


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