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


PHP Console_Getopt::getOpt方法代码示例

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


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

示例1: __construct

 public function __construct()
 {
     require_once 'Console/Getopt.php';
     define('NO_ARGS', 1);
     define('INVALID_OPTION', 2);
     $args = Console_Getopt::readPHPArgv();
     if (count($args) <= 1) {
         $this->usage(true);
         exit(1);
     }
     if (PEAR::isError($args)) {
         fputs(STDERR, $args->getMessage() . "\n");
         exit(NO_ARGS);
     }
     if ($_SERVER['argv'][0] == $_SERVER['SCRIPT_NAME']) {
         $this->opts = Console_Getopt::getOpt($args, $this->short_opts, $this->long_opts);
     } else {
         $this->opts = Console_Getopt::getOpt2($args, $this->short_opts, $this->long_opts);
     }
     // Are the passed options valid?
     if (PEAR::isError($this->opts)) {
         fputs(STDERR, $this->opts->getMessage() . "\n");
         exit(INVALID_OPTION);
     }
     $this->set_cache();
 }
开发者ID:BackupTheBerlios,项目名称:pobs-svn,代码行数:26,代码来源:getopts.class.php

示例2: __construct

 public function __construct()
 {
     $args = Console_Getopt::readPHPArgv();
     if (PEAR::isError($args)) {
         fwrite(STDERR, $args->getMessage() . "\n");
         exit(1);
     }
     // Compatibility between "php script.php" and "./script.php"
     if (realpath($_SERVER['argv'][0]) == __FILE__) {
         $this->options = Console_Getopt::getOpt($args, $this->short_format_config);
     } else {
         $this->options = Console_Getopt::getOpt2($args, $this->short_format_config);
     }
     // Check for invalid options
     if (PEAR::isError($this->options)) {
         fwrite(STDERR, $this->options->getMessage() . "\n");
         $this->help();
     }
     $this->command = array();
     // Loop through the user provided options
     foreach ($this->options[0] as $option) {
         switch ($option[0]) {
             case 'h':
                 help();
                 break;
             case 's':
                 $this->command['syntax'] = $option[1];
                 break;
             case 't':
                 $this->command['transform'] = $option[1];
                 break;
             case 'c':
                 $this->command['config'] = $option[1];
                 break;
         }
     }
     // Loop through the user provided options
     foreach ($this->options[1] as $argument) {
         $this->command['query'] .= ' ' . $argument;
     }
 }
开发者ID:indexdata,项目名称:metaproxy,代码行数:41,代码来源:experiment-query-config-translate.php

示例3: exit

<?php

/*
 * login_multi_ip.php - Finding users logging in using the same IP
 * Copyright (c) 2005  Marcus Lunzenauer
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */
/***** COMMAND LINE *****/
// include PEAR::Console_Getopt
require_once 'Console/Getopt.php';
// check for command line options
$options = Console_Getopt::getOpt(Console_Getopt::readPHPArgv(), 'dht:');
if (PEAR::isError($options)) {
    multiip_usage();
    exit(1);
}
// check for options
$debugFlag = FALSE;
$time_intervall = 12;
foreach ($options[0] as $option) {
    // option h
    if ('h' == $option[0]) {
        multiip_usage();
        exit(1);
        // option d
    } else {
        if ('d' == $option[0]) {
开发者ID:microlefes,项目名称:Game,代码行数:31,代码来源:login_multi_ip.php

示例4: hash_hmac

        $m_token_digest .= $config->get_salt_field();
        // produce the signature and append to the tokenized string
        $signature = hash_hmac($config->get_algo(), rtrim($m_token_digest, $config->get_field_delimiter()), $this->h2b($config->get_key()));
        return $m_token . 'hmac=' . $signature;
    }
}
// CLI Parameter Control
if (!empty($argc) && strstr($argv[0], basename(__FILE__))) {
    // bring in getopt and define some exit codes
    require_once 'Console/Getopt.php';
    define('NO_ARGS', 10);
    define('INVALID_OPTION', 11);
    // parse args to opts
    $args = Console_Getopt::readPHPArgv();
    $long_opts = array('help', 'window=', 'start-time=', 'ip=', 'acl=', 'session-id=', 'payload=', 'url=', 'salt=', 'field-delimiter=', 'acl-delimiter=', 'algo=', 'key=', 'debug', 'escape-early');
    $opts = Console_Getopt::getOpt($args, 'h', $long_opts);
    // Check the options are valid
    if (PEAR::isError($opts)) {
        fwrite(STDERR, $opts->getMessage() . "\n");
        exit(INVALID_OPTION);
    }
    if (!empty($opts[0])) {
        $c = new Akamai_EdgeAuth_Config();
        $g = new Akamai_EdgeAuth_Generate();
        foreach ($opts[0] as $o) {
            if ($o[0] == '--help') {
                //@TODO
                print "php akamai_token_v2.php [options]\n";
                print "ie.\n";
                print "php akamai_token_v2.php --start=now --window=86400\n";
                print "\n";
开发者ID:shortlist-digital,项目名称:agreable-pugpig-plugin,代码行数:31,代码来源:akamai_token_v2.php

示例5: usage

#!@prefix@/bin/php -Cq
<?php 
/**
* PHAIL - stands for PHP Mail
* @author Tomas V.V.Cox <cox@idecnet.com>
*/
require_once 'Mail.php';
require_once 'Mail/mime.php';
require_once 'Console/Getopt.php';
$argv = Console_Getopt::readPHPArgv();
$opts = Console_Getopt::getOpt($argv, 'f:c:s:t:a:b:');
if (PEAR::isError($opts)) {
    usage($opts->getMessage());
}
PEAR::setErrorHandling(PEAR_ERROR_DIE);
$mime =& new Mail_Mime();
foreach ($opts[0] as $opt) {
    $param = $opt[1];
    switch ($opt[0]) {
        case 'f':
            $headers['From'] = $param;
            break;
        case 'c':
            $headers['Cc'] = $param;
            break;
        case 's':
            $headers['Subject'] = $param;
            break;
        case 't':
            $to = $param;
            break;
开发者ID:Bergdahls,项目名称:YetiForceCRM,代码行数:31,代码来源:phail.php

示例6: ini_set

    ini_set('magic_quotes_runtime', FALSE);
    define('STDIN', fopen('php://stdin', 'r'));
    define('STDOUT', fopen('php://stdout', 'w'));
    define('STDERR', fopen('php://stderr', 'w'));
    register_shutdown_function(create_function('', 'fclose(STDIN); fclose(STDOUT); fclose(STDERR); return true;'));
}
require_once 'Console/Getopt.php';
define('SUCCESS', 0);
define('PROBLEM', 1);
define('NO_ARGS', 10);
define('INVALID_OPTION', 11);
$args = Console_Getopt::readPHPArgv();
if (PEAR::isError($args)) {
    fwrite(STDERR, $args->getMessage() . "\n");
    exit(NO_ARGS);
}
$options = Console_Getopt::getOpt($args, $short_opts, $long_opts);
if (PEAR::isError($options)) {
    fwrite(STDERR, $options->getMessage() . "\n");
    exit(INVALID_OPTION);
}
require_once 'error.php';
/* error display to standard error */
function err_display_stderr($num, $str, $file, $line, $context)
{
    $stderr = fopen('php://stderr', 'w');
    fwrite($stderr, "{$file}:{$line}\n{$str}\n");
    fclose($stderr);
}
err_set_handler_display('err_display_stderr');
err_set_handler_log(null);
开发者ID:bruno,项目名称:openaustralia-app,代码行数:31,代码来源:phpcli.php

示例7: help_text

 *   command line help text
 */
function help_text()
{
    return "\n    Options are:\n        --username     - Web Services simple authentication username\n        --password     - Web Services simple authentication password\n        --bausername   - basic authentication username to get past basic auth\n        --bapassword   - basic authentication password to get past basic auth\n        --servicegroup - service group as specified in webservice configuration that contains the necessary functions to call\n        --url          - the URL of the Web Service to call eg: http://your.mahara.local.net/webservice/soap/server.php\n    ";
}
//fetch arguments
$args = Console_Getopt::readPHPArgv();
//checking errors for argument fetching
if (PEAR::isError($args)) {
    error_log('Invalid arguments (1): ' . help_text());
    exit(1);
}
// remove stderr/stdout redirection args
$args = preg_grep('/2>&1/', $args, PREG_GREP_INVERT);
$console_opt = Console_Getopt::getOpt($args, 'u:p:l:s:', array('username=', 'password=', 'url=', 'servicegroup=', 'bausername=', 'bapassword='));
if (PEAR::isError($console_opt)) {
    error_log('Invalid arguments (2): ' . help_text());
    exit(1);
}
// must supply at least one arg for the action to perform
if (count($args) <= 2) {
    error_log('Invalid arguments: you must atleast specify --username and --password' . help_text());
    exit(1);
}
/**
 * Get and check interactive parameters
 *
 * @param string $param
 * @param string $default
 */
开发者ID:rboyatt,项目名称:mahara,代码行数:31,代码来源:example_api_base.php

示例8: array

<?php

/*
 * phc -- the open source PHP compiler
 * See doc/license/README.license for licensing information
 *
 * Handle command line parameters
 */
require_once "Console/Getopt.php";
require_once "Console/ProgressBar.php";
$cg = new Console_Getopt();
$argv = $cg->readPHPArgv();
$getopt = $cg->getOpt($cg->readPHPArgv(), "lvVshnpicqO:Dr", array("long", "verbose", "valgrind", "support", "help", "number", "no-progress", "installed", "clean", "quick", "one", "debug", "reduce"));
if ($getopt instanceof PEAR_Error) {
    die("Command line error: {$getopt->message}\n");
}
list($opts, $arguments) = $getopt;
foreach ($opts as $opt) {
    if ($opt[1] == NULL) {
        $options[$opt[0]] = "";
    } else {
        $options[$opt[0]] = $opt[1];
    }
}
$opt_verbose = isset($options["v"]);
$opt_long = isset($options["l"]);
$opt_valgrind = isset($options["V"]);
$opt_support = isset($options["s"]);
$opt_numbered = isset($options["n"]);
$opt_help = isset($options["h"]);
$opt_no_progress_bar = isset($options["p"]);
开发者ID:michaelprem,项目名称:phc,代码行数:31,代码来源:startup.php


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