本文整理汇总了PHP中usage函数的典型用法代码示例。如果您正苦于以下问题:PHP usage函数的具体用法?PHP usage怎么用?PHP usage使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了usage函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: validateCommands
/**
* Validate command arguments
*
* @return void
*/
function validateCommands()
{
if (!isset($_SERVER['argv'][1]) || 'install' !== $_SERVER['argv'][1]) {
echo usage();
exit;
}
}
开发者ID:asika32764,项目名称:sms-phpstorm-config-installer,代码行数:12,代码来源:main.php
示例2: main
function main($argv)
{
$cmd = array_shift($argv);
if (count($argv) == 0) {
usage($cmd);
exit(2);
}
foreach ($argv as $arg) {
if ($arg == "--help") {
usage($cmd);
exit(2);
}
}
$dbname = $argv[0];
$collectionName = count($argv) >= 2 ? $argv[1] : "languages";
$data = parse_registry("language-subtag-registry.txt");
echo "Writing language data to collection \"{$collectionName}\" in Mongo database \"{$dbname}\"... ";
$m = new MongoClient();
$db = $m->{$dbname};
$coll = $db->{$collectionName};
$coll->drop();
// Replace old data with new, don't append
$coll->batchInsert($data);
echo "done.\n";
}
开发者ID:bbriggs,项目名称:web-languageforge,代码行数:25,代码来源:setup-language-registry.php
示例3: getConfig
/**
* Returns a new configuration object
*
* @param array $confPaths List of configuration paths from the bootstrap object
* @param array $options Associative list of configuration options as key/value pairs
* @return \Aimeos\MW\Config\Iface Configuration object
*/
function getConfig(array $confPaths, array $options)
{
$config = array();
if (isset($options['config'])) {
foreach ((array) $options['config'] as $path) {
if (is_file($path)) {
$config = array_replace_recursive($config, require $path);
} else {
$confPaths[] = $path;
}
}
}
$conf = new \Aimeos\MW\Config\PHPArray($config, $confPaths);
$conf = new \Aimeos\MW\Config\Decorator\Memory($conf);
if (isset($options['option'])) {
foreach ((array) $options['option'] as $option) {
$parts = explode(':', $option);
if (count($parts) !== 2) {
printf("Invalid config option \"%1\$s\"\n", $option);
usage();
}
$conf->set($parts[0], $parts[1]);
}
}
return $conf;
}
开发者ID:nos3,项目名称:aimeos-core,代码行数:33,代码来源:setup.php
示例4: main
function main($argv, $argc)
{
if ($argc >= 2 && $argc <= 4) {
$students = array("add_student", "del_student", "update_student", "show_student", "show_movies", "movies_storing", "show_stat");
$options_w = array("show_rented_movies", "show_renting_students");
$rent = array("rent_movie", "return_movie");
$m = new MongoClient();
$db = $m->db_etna;
if (in_array($argv[1], $students)) {
$argv[1]($db, $argv);
} else {
if (in_array($argv[1], $options_w) && $argc == 2) {
$argv[1]($db);
} else {
if (in_array($argv[1], $rent) && $argc == 4) {
$argv[1]($db, $argv);
} else {
echo "Error: Commande non definie.\n";
return 0;
}
}
}
} else {
echo "[31mError: Nombre d'arguments incorrect.[0m\n";
usage();
}
}
开发者ID:amira-s,项目名称:etna-projects,代码行数:27,代码来源:etna_movies.php
示例5: flagval
/**
* Finds the next value of input flags, returns it and advances i
*
* @param int $i The flag counter
* @param array $argv The array with cli flags.
* @returns string The value of the switch at i.
*/
function flagval(&$i, $argv)
{
if (empty($argv[$i + 1])) {
usage();
}
return $argv[++$i];
}
开发者ID:noseglid,项目名称:phpa,代码行数:14,代码来源:phpa.php
示例6: parse_arguments
function parse_arguments()
{
global $args;
$opts = getopt('f:p:s:d:lh');
foreach ($opts as $k => $v) {
switch ($k) {
case 'f':
$args->future = $v;
break;
case 'p':
$args->near_past = $v;
break;
case 's':
$_SERVER['SERVER_NAME'] = $v;
break;
case 'd':
$args->debug = true;
$debugging = explode(',', $v);
break;
case 'l':
$args->set_last = true;
break;
case 'h':
usage();
break;
default:
$args->{$k} = $v;
}
}
}
开发者ID:derekyu1437,项目名称:davical,代码行数:30,代码来源:refresh-alarms.php
示例7: main
function main()
{
$args = $_SERVER['argv'];
$script = array_shift($args);
if (!count($args)) {
usage($script);
}
$current = array_shift($args);
if (!count($args)) {
echo PHP_EOL;
}
$components = explode(',', array_shift($args));
$paths = array();
$base = dirname(dirname(dirname(dirname(dirname(__FILE__)))));
foreach ($components as $component) {
if ($current == '-') {
$parts = array('', 'tmp', 'tagfiles');
} else {
$parts = array($base, $component);
}
$parts[] = $component . '.tagfile.xml';
$path = implode(DIRECTORY_SEPARATOR, $parts);
$paths[$path] = $current == '-' ? '../../' . $component . '/html' : dirname($path) . DIRECTORY_SEPARATOR . 'docs' . DIRECTORY_SEPARATOR . 'api' . DIRECTORY_SEPARATOR . 'html';
}
foreach ($paths as $tagfile => $relative) {
echo "\"{$tagfile}={$relative}\" ";
}
echo PHP_EOL;
exit(0);
}
开发者ID:erebot,项目名称:buildenv,代码行数:30,代码来源:get_filetags.php
示例8: process_parameters
function process_parameters(&$a, &$b, &$c)
{
global $argc, $argv;
$a = null;
$b = null;
$c = null;
if ($argc != 4) {
// first is executable file
usage();
}
for ($i = 1; $i < $argc; $i++) {
if (strpos($argv[$i], "a=") === 0) {
$la = substr($argv[$i], 2);
} else {
if (strpos($argv[$i], "b=") === 0) {
$lb = substr($argv[$i], 2);
} else {
if (strpos($argv[$i], "c=") === 0) {
$lc = substr($argv[$i], 2);
}
}
}
}
if (!isset($la) || !isset($lb) || !isset($lc)) {
usage();
}
$a = $la;
$b = $lb;
$c = $lc;
}
开发者ID:dw4dev,项目名称:Phalanger,代码行数:30,代码来源:Program.php
示例9: verify_changelog
function verify_changelog($filename)
{
if (!file_exists($filename)) {
echo "Missing ChangeLog file!\n";
echo "Need pre-populated {$filename}\n";
echo "Did you forget to run \$ make ChangeLog ?\n";
usage();
}
}
开发者ID:dogrocker,项目名称:mongo-php-driver,代码行数:9,代码来源:prep-release.php
示例10: main
function main()
{
$opts = getopt("cath");
if (isset($opts['h']) || !isset($opts['a']) && !isset($opts['t'])) {
usage();
}
if (isset($opts['a']) && isset($opts['t'])) {
fatal("can't use -a and -t together");
}
$mode = isset($opts['t']) ? 'tx' : 'address';
if (isset($opts['c'])) {
switch ($mode) {
case "tx":
echo <<<'EOD'
DROP TABLE t_shortlinks;
CREATE TABLE t_shortlinks (
shortcut bytea NOT NULL PRIMARY KEY,
hash bytea NOT NULL REFERENCES transactions
);
ALTER TABLE public.t_shortlinks OWNER TO blockupdate;
GRANT SELECT ON TABLE t_shortlinks TO "www-data";
EOD;
break;
case "address":
echo <<<'EOD'
DROP TABLE a_shortlinks;
CREATE TABLE a_shortlinks (
shortcut bytea NOT NULL PRIMARY KEY,
hash160 bytea NOT NULL REFERENCES keys
);
ALTER TABLE public.a_shortlinks OWNER TO blockupdate;
GRANT SELECT ON TABLE a_shortlinks TO "www-data";
EOD;
break;
}
}
$fh = fopen("php://stdin", "r");
while ($line = trim(fgets($fh))) {
$arr = explode(" ", $line);
if ($mode == "tx") {
$shortcut_hex = decodeBase58($arr[0]);
$tx_hex = $arr[1];
echo "INSERT INTO t_shortlinks(shortcut, hash) VALUES (decode('{$shortcut_hex}', 'hex'), decode('{$tx_hex}', 'hex'));\n";
} elseif ($mode == "address") {
$shortcut_hex = decodeBase58($arr[0]);
$hash160_hex = addressToHash160($arr[1]);
echo "INSERT INTO a_shortlinks(shortcut, hash160) VALUES (decode('{$shortcut_hex}', 'hex'), decode('{$hash160_hex}', 'hex'));\n";
}
}
}
开发者ID:blockexplorers,项目名称:blockexplorer,代码行数:56,代码来源:update_shortlinks.php
示例11: parseArgs
public function parseArgs()
{
global $argc, $argv;
if ($argc != 2) {
usage();
return false;
}
$this->scriptsXmlFile = $argv[1];
return true;
}
开发者ID:fruition-sciences,项目名称:phpfw,代码行数:10,代码来源:UpgradeDB.php
示例12: check_input_parameters
function check_input_parameters($options)
{
if (!count($options) || isset($options['h']) || isset($options['help'])) {
usage();
}
if (!isset($options['bucket']) || !isset($options['file']) || !isset($options['to'])) {
print "Error: Missing mandatory parameter !\n";
usage();
}
}
开发者ID:santihbc,项目名称:CloudTranscode,代码行数:10,代码来源:getFromS3.php
示例13: main
function main()
{
if ($_SERVER['argc'] <= 1 || false === is_dir($_SERVER['argv'][1])) {
echo usage();
exit(-1);
} else {
setup();
init($_SERVER['argv'][1]);
}
}
开发者ID:BackupTheBerlios,项目名称:medick-svn,代码行数:10,代码来源:runner.php
示例14: parseArgs
public function parseArgs()
{
global $argc, $argv;
if ($argc != 4) {
usage();
return false;
}
$this->beanDescriptorsDir = $argv[1];
$this->templetsDir = $argv[2];
$this->beansOutputDir = $argv[3];
return true;
}
开发者ID:fruition-sciences,项目名称:phpfw,代码行数:12,代码来源:GenerateBeans.php
示例15: trax
function trax()
{
global $search, $replace, $quiet;
// Get command line argument, if any
if (!array_key_exists('argc', $GLOBALS) || $GLOBALS['argc'] < 2) {
usage();
// print Usage message and exit
}
$first_param_is_option = substr($GLOBALS['argv'][1], 0, 1) == "-" ? true : false;
// Check for excess arguments
if ($GLOBALS['argc'] > 3 && !$first_param_is_option) {
echo "unrecognized command argument " . $GLOBALS['argv'][2] . "\n";
usage();
}
if ($first_param_is_option) {
foreach ($GLOBALS['argv'] as $arg) {
if ($arg == '-v' || $arg == '--version') {
include dirname(__FILE__) . "/vendor/trax/trax.php";
echo "Trax " . Trax::version() . "\n";
exit;
} elseif ($arg == '-h' || $arg == '--help') {
usage();
}
}
} else {
// Destination directory on command line
$dstdir = $GLOBALS['argv'][1];
if ($GLOBALS['argv'][2] == '-q' || $GLOBALS['argv'][2] == '--quiet') {
$quiet = true;
}
}
// Guarantee it ends with DIRECTORY_SEPARATOR
if (substr($dstdir, -1, 1) != DIRECTORY_SEPARATOR) {
$dstdir .= DIRECTORY_SEPARATOR;
}
if (!create_dir($dstdir)) {
return;
}
// Assign real values for symbol substitution
$replace[0] = realpath($dstdir) . '/config';
// actual value of
// the full filesystem path to the
// Trax config/ directory in the
// user's work area
// copy source directory to destination directory
copy_dir(SOURCE_DIR, $dstdir);
$dstdir .= 'vendor/trax/';
if (!create_dir($dstdir)) {
return;
}
// copy trax core code to vendor folder of project
copy_dir(TRAX_SOURCE_DIR, $dstdir);
}
开发者ID:phpontrax,项目名称:trax,代码行数:53,代码来源:trax.php
示例16: parse_arguments
function parse_arguments(&$argv)
{
// Default options
$defaults = array('i' => 'localhost', 'p' => '8000', "mime-file" => "/etc/mime.types", "wp-root" => ".", "wp-version" => "latest", "show-errors" => 'E_ALL', "show-assets" => false, "show-hooks" => '', "show-everything" => false, "wordpresses" => $_SERVER['HOME'] . "/.cache/whippet/wordpresses", "cb-cache" => $_SERVER['HOME'] . "/.cache/whippet/callback-cache", "multisite" => false);
// Are there some options in a config file? Check them in order.
if (file_exists("/etc/whippetrc")) {
$defaults = array_merge($defaults, parse_ini_file("/etc/whippetrc"));
}
if (!empty($_SERVER['HOME']) && file_exists($_SERVER['HOME'] . "/.whippetrc")) {
$defaults = array_merge($defaults, parse_ini_file($_SERVER['HOME'] . "/.whippetrc"));
}
$optparser = new OptionParser();
$optparser->addRule('h|help');
$optparser->addRule('i::');
$optparser->addRule('p::');
$optparser->addRule('siteurl::');
$optparser->addRule('q');
$optparser->addRule('multisite');
$optparser->addRule('mime-file::');
$optparser->addRule('no-sql');
$optparser->addRule('no-templates');
$optparser->addRule('no-params');
$optparser->addRule('no-scripts');
$optparser->addRule('show-assets');
$optparser->addRule('show-wp-errors');
$optparser->addRule('show-wp-queries');
$optparser->addRule('show-wp-hooks');
$optparser->addRule('show-errors::');
$optparser->addRule('show-everything');
$optparser->addRule('wp-version::');
$optparser->addRule('show-hooks::');
$optparser->addRule('wordpresses::');
try {
$argv = $optparser->parse();
} catch (Exception $e) {
echo Colours::fg('red') . "Error: " . Colours::fg("white") . $e->getMessage() . "\n\n";
usage();
exit(0);
}
$arguments = $optparser->getAllOptions();
if (!isset($arguments->siteurl)) {
$i = isset($arguments['i']) ? $arguments['i'] : $defaults['i'];
$p = isset($arguments['p']) ? $arguments['p'] : $defaults['p'];
if ($p == 80) {
$defaults['siteurl'] = "http://{$i}/";
} else {
$defaults['siteurl'] = "http://{$i}:{$p}/";
}
}
return array_merge($defaults, $arguments);
}
开发者ID:dxw,项目名称:whippet-server,代码行数:51,代码来源:launcher-functions.php
示例17: proc_args
/**
* procc the request
*/
function proc_args()
{
global $args;
switch ($args[0]) {
case 'run_scrape':
$MV_BillScraper = new MV_BillScraper();
$MV_BillScraper->procArguments();
$MV_BillScraper->doScrapeInsert();
break;
default:
usage();
break;
}
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:17,代码来源:scrape_and_insert.php
示例18: init
function init($argv, $argc)
{
print "MySQL replace tool (replace.php)\nCopyright (C) 2012 Nick Bolton\n";
if ($argc < 5) {
echo "not enough args\n";
usage();
exit(1);
}
$context = new stdClass();
for ($i = 1; $i < $argc - 1; $i++) {
$arg = $argv[$i];
switch ($arg) {
case "--table":
$context->table = $argv[++$i];
break;
case "--field":
$context->field = $argv[++$i];
break;
case "--find":
$context->find = $argv[++$i];
break;
case "--replace":
$context->replace = $argv[++$i];
break;
default:
echo "invalid arg: {$arg}\n";
usage();
exit(2);
}
}
print sprintf("\noptions:\n table: %s\n field: %s\n find: %s\n replace: %s\n", $context->table, $context->field, $context->find, $context->replace);
if (!file_exists("settings.ini")) {
echo "missing: settings.ini";
exit(3);
}
$ini = parse_ini_file("settings.ini", true);
$host = $ini["db"]["host"];
$user = $ini["db"]["user"];
$password = $ini["db"]["password"];
$database = $ini["db"]["database"];
$hasPassword = $password != null ? "yes" : "no";
print "\ndatabase:\n host: {$host} \n user: {$user} \n password: {$hasPassword} \n database: {$database} \n";
$sql = new mysqli($host, $user, $password, $database);
if ($sql->connect_errno) {
throw new Exception("failed to connect to mysql: " . $sql->connect_error);
}
$sql->set_charset("utf8");
$context->sql = $sql;
return $context;
}
开发者ID:xian310,项目名称:spit,代码行数:50,代码来源:replace.php
示例19: getparam
function getparam($param, $opt = '')
{
global $argv;
foreach ($argv as $value => $key) {
if ($key == '-' . $param) {
return $argv[$value + 1];
}
}
if ($opt) {
usage();
} else {
return FALSE;
}
}
开发者ID:SuperQcheng,项目名称:exploit-database,代码行数:14,代码来源:4608.php
示例20: multiargument
function multiargument($flag, $legal_values)
{
parent::anyargument($flag);
if (!$this->set) {
return;
}
$map = array();
foreach ($legal_values as $value) {
$map[$value] = true;
}
if (!isset($map[$this->value])) {
usage("{$this->value} is not a valid parameter to --{$flag}!");
exit(1);
}
}
开发者ID:888,项目名称:hs-nacl,代码行数:15,代码来源:build-nix.php
注:本文中的usage函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论