本文整理匯總了PHP中print_help函數的典型用法代碼示例。如果您正苦於以下問題:PHP print_help函數的具體用法?PHP print_help怎麽用?PHP print_help使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了print_help函數的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: main
function main($args)
{
//input sanity check
if (!is_array($args) || is_array($args) && !array_key_exists('name', $args)) {
print_help(true);
}
$migration_name = $args['name'];
//clear any filesystem stats cache
clearstatcache();
//check to make sure our migration directory exists
if (!is_dir(MIGRATION_DIR)) {
die_with_error("ERROR: migration directory '" . MIGRATION_DIR . "' does not exist. Specify MIGRATION_DIR in config/config.inc.php and try again.");
}
//generate a complete complete
$highest_version = VersionUtil::get_highest_migration(MIGRATION_DIR);
$next_version = VersionUtil::to_migration_number($highest_version + 1);
$klass = NamingUtil::camelcase($migration_name);
$file_name = $next_version . '_' . $klass . '.php';
$full_path = realpath(MIGRATION_DIR) . '/' . $file_name;
$template_str = get_template($klass);
//check to make sure our destination directory is writable
if (!is_writable(MIGRATION_DIR . '/')) {
die_with_error("ERROR: migration directory '" . MIGRATION_DIR . "' is not writable by the current user. Check permissions and try again.");
}
//write it out!
$file_result = file_put_contents($full_path, $template_str);
if ($file_result === FALSE) {
die_with_error("Error writing to migrations directory/file. Do you have sufficient privileges?");
} else {
echo "\nCreated migration: {$file_name}\n\n";
}
}
示例2: main
/**
* Application main function. Retrieves cli args and runs engine.
*/
function main()
{
$opt = getopt("D:d:h:u:p:o:v:m:n:c:t:s:xw?");
if (@$opt['?'] || !@$opt['d']) {
print_help();
return -1;
}
$config = array();
$config['db'] = get_option($opt, 'd');
$config['host'] = get_option($opt, 'h', 'localhost');
$config['user'] = get_option($opt, 'u', 'root');
$config['pass'] = get_option($opt, 'p', '');
$config['namespace_prefix'] = get_option($opt, 'n', '');
$config['verbosity'] = get_option($opt, 'v', 1);
$config['output_dir'] = get_option($opt, 'm', './cdc_audit_sync');
$config['tables'] = get_option($opt, 't', null);
$config['wipe'] = isset($opt['w']) ? true : false;
$config['stdout'] = STDOUT;
if (isset($opt['o'])) {
$fh = fopen($opt['o'], 'w');
if (!$fh) {
die("Could not open {$opt['o']} for writing");
}
$config['stdout'] = $fh;
}
$engine = new cdc_audit_sync_mysql($config);
$success = $engine->run();
fclose($config['stdout']);
return $success ? 0 : -1;
}
示例3: process
function process($arguments)
{
$dump_data = false;
$term = get_term_default();
array_shift($arguments);
if (!isset($arguments[0])) {
$arguments[0] = '-h';
}
$argCount = count($arguments);
for ($i = 0; $i < $argCount; $i++) {
if ($arguments[$i] == '-h') {
print_help();
exit;
} elseif ($arguments[$i] == '-f') {
$i++;
if (!isset($arguments[$i])) {
exit("Configuration file not included.\n");
}
$file_directory = $arguments[$i];
} elseif ($arguments[$i] == '-n') {
$i++;
if (!isset($arguments[$i])) {
exit("Student rows not included.\n");
}
$number_of_students = $arguments[$i];
} elseif ($arguments[$i] == '-x') {
$dump_data = true;
} elseif ($arguments[$i] == '-t') {
$i++;
if (!isset($arguments[$i])) {
exit("Term is missing.\n");
}
$term = $arguments[$i];
} else {
exit("Unknown command\n");
}
}
if (empty($number_of_students)) {
$number_of_students = NUMBER_OF_STUDENTS;
}
include_database_file($file_directory);
if ($dump_data) {
$response = readline("Are you sure you want to reset ALL your student tables? (y/N):");
if ($response == 'y') {
reset_tables();
} else {
echo "Ending script.\n\n";
exit;
}
echo "\nReset complete.\n------------------------------------\n\n";
}
build_table();
echo TABLE_NAME . " table created.\n";
echo "------------------------------------\n\n";
echo "Creating {$number_of_students} students.\n\n";
insert_rows($number_of_students, $term);
echo "------------------------------------\nStudent creation complete.\n\n";
echo "Make sure your inc/hms_defines.php file contains the following setting:\ndefine('SOAP_OVERRIDE_FILE', 'FakeSoapTable.php');\n";
}
示例4: parse_args
function parse_args($argv)
{
$num_args = count($argv);
if ($num_args < 2) {
print_help(true);
}
$migration_name = $argv[1];
return array('name' => $migration_name);
}
示例5: process_cli_params
function process_cli_params($params)
{
$success = 0;
// 0 == success.
if (isset($params['version'])) {
print_version();
return [$params, 2];
}
if (isset($params['help']) || !isset($params['g'])) {
print_help();
return [$params, 1];
}
if (@$params['logfile']) {
mylogger()->set_log_file($params['logfile']);
mylogger()->echo_log = false;
}
$loglevel = @$params['loglevel'] ?: 'info';
mylogger()->set_log_level_by_name($loglevel);
$xpublist = get_xpub_list($params, $empty_ok = true);
$params['derivation'] = @$params['derivation'] ?: 'relative';
$params['include-unused'] = isset($params['include-unused']) ? true : false;
$params['multisig'] = count($xpublist) > 1;
// legacy copay used multisig even for 1 of 1 wallets.
if ($params['derivation'] == 'copaylegacy') {
$params['multisig'] = true;
// if numsig is missing for 1of1 then we set it to 1.
$params['numsig'] = @$params['numsig'] ?: (count($xpublist) == 1 ? 1 : null);
}
$params['gen-only'] = is_numeric(@$params['gen-only']) ? $params['gen-only'] : null;
$types = array('receive', 'change', 'both');
$params['type'] = in_array(@$params['type'], $types) ? $params['type'] : 'both';
if (count($xpublist) > 1 && !@$params['numsig']) {
throw new Exception("multisig requires --numsig");
}
$params['gap-limit'] = @$params['gap-limit'] ?: 20;
$params['batch-size'] = @$params['batch-size'] ?: 'auto';
$params['cols'] = get_cols($params);
$params['min-receive'] = is_numeric(@$params['min-receive']) ? $params['min-receive'] : 0;
$params['min-change'] = is_numeric(@$params['min-change']) ? @$params['min-change'] : 0;
$params['api'] = @$params['api'] ?: 'blockchaindotinfo';
$params['insight'] = @$params['insight'] ?: 'https://insight.bitpay.com/api';
$params['blockchaindotinfo'] = @@$params['blockchaindotinfo'] ?: 'https://blockchain.info';
$params['toshi'] = @$params['toshi'] ?: 'https://bitcoin.toshi.io';
$params['blockr'] = @$params['blockr'] ?: 'https://btc.blockr.io';
$params['format'] = @$params['format'] ?: 'txt';
$params['cols'] = @$params['cols'] ?: 'all';
$params['oracle-raw'] = @$params['oracle-raw'] ?: null;
$params['oracle-json'] = @$params['oracle-json'] ?: null;
return [$params, $success];
}
示例6: validate_args
function validate_args($argv, $argc)
{
if ($argc != 2) {
echo "Wrong number of parameters.\n";
return 1;
}
if ($argv[1] == '--help') {
print_help();
return 1;
} else {
if (!file_exists($argv[1])) {
echo "File does not exists: {$argv[1]}\n";
return 1;
}
}
return 0;
}
示例7: getopt
#debug mode
#$debug = 'ON';
$debug = 'OFF';
# ARGUMENTS PROCESSING
#save options passed to the script
$options = getopt($shortoptions, $longoptions);
#get number of options
$arg_num = $argc - 1;
#check options (duplicity and validity)
if ($arg_num != count($options, COUNT_RECURSIVE)) {
exit(ARG_ERR);
}
#in case of --help
if (isset($options['help'])) {
if ($arg_num == 1) {
print_help();
exit(NO_ERR);
} else {
exit(ARG_ERR);
}
}
#read input file or read stdin
if (isset($options['input'])) {
if (false === ($ifile = file_get_contents($options['input']))) {
exit(READ_ERR);
}
} else {
$ifile = file_get_contents('php://stdin');
}
if ($debug == 'ON') {
echo "INPUT:\n";
示例8: str_replace
$files[$file] = str_replace('//', '/', $path . '/' . $file);
}
}
}
closedir($dh);
} else {
print "ERROR: The path you requested cannot be read! \n ";
print "\n";
print_help($argv);
exit;
}
// check if there is the default language defined
if (!isset($files[$baseLanguage])) {
print "ERROR: The baselanguage cannot be found! \n";
print "\n";
print_help($argv);
exit;
}
// import the baselanguage
$base = import($files[$baseLanguage]);
// and unset it in the files, because we don't need to compare base to base
unset($files[$baseLanguage]);
// compare each language with the baselanguage
foreach ($files as $key => $file) {
$comp = import($file);
print "\n\nComparing " . $baseLanguage . " to " . $key . "\n";
$result = compare($base, $comp);
if (is_array($result) && sizeof($result) > 0) {
print " found missing strings: \n";
foreach ($result as $value) {
print " " . $value . "\n";
示例9: parse_arguments
/**
* Parses the cli arguments.
*
* @return Boolean that indicates whether the given arguments are
* fine.
*/
function parse_arguments()
{
global $argv;
if (!isset($argv)) {
if (false === (bool) ini_get('register_argc_argv')) {
error_log('[ERROR] Please enable register_argc_argv in your php.ini.');
} else {
error_log('[ERROR] No $argv array available.');
}
echo PHP_EOL;
return false;
}
// Remove the script name (first argument)
global $scriptname;
$scriptname = array_shift($argv);
if (count($argv) === 0) {
error_log('[ERROR] Missing argument.');
return false;
}
// Set the path and remove from command line (last argument)
global $path;
$path = (string) array_pop($argv);
// Parse options
$longopts = ["help", "version", "format:", "nodes:", "relationships:"];
$options = getopt("hvf:n:r:", $longopts);
if ($options === FALSE) {
error_log('[ERROR] Could not parse command line arguments.');
return false;
}
// Help?
if (isset($options['help']) || isset($options['h'])) {
print_version();
echo PHP_EOL;
print_usage();
echo PHP_EOL;
print_help();
exit(0);
}
// Version?
if (isset($options['version']) || isset($options['v'])) {
print_version();
exit(0);
}
// Format?
if (isset($options['format']) || isset($options['f'])) {
global $format;
switch ($options['format'] ?? $options['f']) {
case "jexp":
$format = CSVExporter::JEXP_FORMAT;
break;
case "neo4j":
$format = CSVExporter::NEO4J_FORMAT;
break;
default:
error_log("[WARNING] Unknown format '{$options['f']}', using neo4j format.");
$format = CSVExporter::NEO4J_FORMAT;
break;
}
}
// Nodes file?
if (isset($options['nodes']) || isset($options['n'])) {
global $nodefile;
$nodefile = $options['nodes'] ?? $options['n'];
}
// Relationships file?
if (isset($options['relationships']) || isset($options['r'])) {
global $relfile;
$relfile = $options['relationships'] ?? $options['r'];
}
return true;
}
示例10: add_device
$device_id = add_device($hostname, NULL, $snmp_port, $snmp_transport, $snmp_options);
}
if ($device_id) {
if (!isset($options['t'])) {
$device = device_by_id_cache($device_id);
print_success("Added device " . $device['hostname'] . " (" . $device_id . ").");
}
// Else this is device testing, success message already written by add_device()
$added++;
}
}
}
$count = count($add_array);
$failed = $count - $added;
if ($added) {
print_message("\nDevices success: {$added}.");
if ($failed) {
print_message("Devices failed: {$failed}.");
}
} else {
if ($count) {
print_message("Devices failed: {$failed}.");
}
print_help($scriptname);
}
function print_help($scriptname)
{
global $config;
print_message("%n\nUSAGE:\n{$scriptname} <hostname> [community] [v1|v2c] [port] [" . implode("|", $config['snmp']['transports']) . "]\n{$scriptname} <hostname> [any|nanp|anp|ap] [v3] [user] [password] [enckey] [md5|sha] [aes|des] [port] [" . implode("|", $config['snmp']['transports']) . "]\n{$scriptname} <filename>\n\nEXAMPLE:\n%WSNMPv1/2c%n: {$scriptname} <%Whostname%n> [community] [v1|v2c] [port] [" . implode("|", $config['snmp']['transports']) . "]\n%WSNMPv3%n : Defaults : {$scriptname} <%Whostname%n> any v3 [user] [port] [" . implode("|", $config['snmp']['transports']) . "]\n No Auth, No Priv : {$scriptname} <%Whostname%n> nanp v3 [user] [port] [" . implode("|", $config['snmp']['transports']) . "]\n Auth, No Priv : {$scriptname} <%Whostname%n> anp v3 <user> <password> [md5|sha] [port] [" . implode("|", $config['snmp']['transports']) . "]\n Auth, Priv : {$scriptname} <%Whostname%n> ap v3 <user> <password> <enckey> [md5|sha] [aes|des] [port] [" . implode("|", $config['snmp']['transports']) . "]\n%WFILE%n : {$scriptname} <%Wfilename%n>\n\nADD FROM FILE:\n To add multiple devices, create a file in which each line contains one device with or without options.\n Format for device options, the same as specified in USAGE.\n\nOPTIONS:\n -p Skip icmp echo checks, device added only by SNMP checks\n\nDEBUGGING OPTIONS:\n -d Enable debugging output.\n -dd More verbose debugging output.\n -t Do not add device(s), only test auth options.", 'color', FALSE);
}
// EOF
示例11: switch
$input_file = "";
$output_dir = "";
for ($i = 1; $i < $argc;) {
$arg = $argv[$i++];
switch ($arg) {
case "--name":
$name = $argv[$i++];
break;
case "--input-file":
$input_file = $argv[$i++];
break;
case "--output-dir":
$output_dir = $argv[$i++];
break;
case "--help":
print_help($argv[0]);
exit(0);
default:
fatal_error("Unknown option: {$arg}");
}
}
if ($name == "") {
fatal_error("--name missing");
}
if ($input_file == "") {
fatal_error("--input-file missing");
}
if ($output_dir == "") {
fatal_error("--output-dir missing");
}
if (($data = file_get_contents($input_file)) === FALSE) {
示例12: print_help
break;
case 'h':
print_help($prog, $defaultOutputDir);
exit(0);
break;
default:
die("{$prog}: usage error: unknown option: -{$opt} (-h for help)\n");
break;
}
} else {
array_push($args, $argv[$i]);
}
}
$queryBins = $isAllBins ? array() : $args;
if (!$isAllBins && count($queryBins) == 0) {
print_help($prog, $defaultOutputDir);
exit(0);
}
// All query bins
if ($isAllBins) {
// Export all of the query bins
$queryBins = getAllbins();
if (count($queryBins) == 0) {
die("{$prog}: no query bins exist in this deployment of TCAT)\n");
}
sort($queryBins);
} else {
// Check query bin names are valid
foreach ($queryBins as $bin) {
$bintype = getBinType($queryBins[0]);
if ($bintype === false) {
示例13: error_log
$max_sprite_height = $value;
continue 2;
case "padding":
$sprite_padding = $value;
continue 2;
}
}
error_log("No switch argument for '{$switch}' defined");
exit(1);
} else {
// must be a SVN url
$svn_urls[] = $argv[$i];
}
}
if (!$input || !$output_sprites) {
print_help(STDERR);
return 1;
}
// generate a random parameter to add to the output_png to ensure that the browser requests the most recent version
$rand_param = "?" . sprintf("%04x", rand(0, 0xffff));
// calculate $relative - the relative path that this script needs to add to access CSS, images etc
$relative = "";
if (strpos($input, "/") !== false) {
$relative = substr($input, 0, strrpos($input, "/") + 1);
}
// first, read the stylesheet, generating rules
if (!file_exists($input)) {
throw new SpritifyException("Input CSS file '{$input}' does not exist");
}
$input_file = file_get_contents($input);
// drop all comments
示例14: process
function process($arguments)
{
$hash = null;
$name = null;
$module = null;
$file_directory = null;
array_shift($arguments);
if (!isset($arguments[0])) {
$arguments[0] = '-h';
}
for ($i = 0; $i < count($arguments); $i++) {
if ($arguments[$i] == '-h') {
print_help();
exit;
} elseif ($arguments[$i] == '-f') {
$i++;
if (!isset($arguments[$i])) {
exit("Configuration file not included.\n");
}
$file_directory = $arguments[$i];
} elseif ($arguments[$i] == '-H') {
$i++;
if (!isset($arguments[$i])) {
exit("Hash not included.\n");
}
$hash = $arguments[$i];
} elseif ($arguments[$i] == '-n') {
$i++;
if (!isset($arguments[$i])) {
exit("Name not included.\n");
}
$name = $arguments[$i];
} elseif ($arguments[$i] == '-m') {
$i++;
if (!isset($arguments[$i])) {
exit("Module not included.\n");
}
$module = $arguments[$i];
}
}
if (!isset($file_directory)) {
echo 'Error: You must include a file directory. See "pulse.php -h"';
}
include_config_file($file_directory);
chdir(PHPWS_SOURCE_DIR);
// Helps with Security include
$_SERVER['REQUEST_URI'] = 'pulse.php';
require_once PHPWS_SOURCE_DIR . 'inc/Bootstrap.php';
require_once PHPWS_SOURCE_DIR . 'core/conf/defines.php';
require_once PHPWS_SOURCE_DIR . 'mod/pulse/class/PulseController.php';
try {
$request = new \Request('index.php', Request::GET);
if (!empty($hash)) {
$request->setVar('hash', $hash);
}
if (!empty($name)) {
$request->setVar('name', $name);
}
if (!empty($module)) {
$request->setVar('schedule_module', $module);
}
\pulse\PulseController::runSchedules($request);
} catch (\Exception $e) {
echo "Error:\n";
echo $e->getMessage();
echo "\n\n";
}
}