本文整理汇总了PHP中PhutilArgumentParser::setSynopsis方法的典型用法代码示例。如果您正苦于以下问题:PHP PhutilArgumentParser::setSynopsis方法的具体用法?PHP PhutilArgumentParser::setSynopsis怎么用?PHP PhutilArgumentParser::setSynopsis使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhutilArgumentParser
的用法示例。
在下文中一共展示了PhutilArgumentParser::setSynopsis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dirname
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('manage open Audit requests');
$args->setSynopsis(<<<EOSYNOPSIS
**audit.php** __repository_callsign__
Close all open audit requests in a repository. This is intended to
reset the state of an imported repository which triggered a bunch of
spurious audit requests during import.
EOSYNOPSIS
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'more', 'wildcard' => true)));
$more = $args->getArg('more');
if (count($more) !== 1) {
$args->printHelpAndExit();
}
$callsign = reset($more);
$repository = id(new PhabricatorRepository())->loadOneWhere('callsign = %s', $callsign);
if (!$repository) {
throw new Exception("No repository exists with callsign '{$callsign}'!");
}
$ok = phutil_console_confirm('This will reset all open audit requests ("Audit Required" or "Concern ' . 'Raised") for commits in this repository to "Audit Not Required". This ' . 'operation destroys information and can not be undone! Are you sure ' . 'you want to proceed?');
示例2: dirname
#!/usr/bin/env php
<?php
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('manage celerity');
$args->setSynopsis(<<<EOSYNOPSIS
**celerity** __command__ [__options__]
Manage static resources.
EOSYNOPSIS
);
$args->parseStandardArguments();
$workflows = id(new PhutilSymbolLoader())->setAncestorClass('CelerityManagementWorkflow')->loadObjects();
$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
示例3: dirname
#!/usr/bin/env php
<?php
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('test InteractiveEditor class');
$args->setSynopsis(<<<EOHELP
**interactive_editor.php** [__options__]
Edit some content via the InteractiveEditor class. This script
makes it easier to test changes to InteractiveEditor, which is
difficult to unit test.
EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'fallback', 'param' => 'editor', 'help' => 'Set the fallback editor.'), array('name' => 'line', 'short' => 'l', 'param' => 'number', 'help' => 'Open at line number __number__.'), array('name' => 'name', 'param' => 'filename', 'help' => 'Set edited file name.')));
if ($args->getArg('help')) {
$args->printHelpAndExit();
}
$editor = new PhutilInteractiveEditor("The wizard quickly\n" . "jinxed the gnomes\n" . "before they vaporized.");
$name = $args->getArg('name');
if ($name) {
$editor->setName($name);
}
$line = $args->getArg('line');
if ($line) {
$editor->setLineOffset($line);
}
$fallback = $args->getArg('fallback');
if ($fallback) {
$editor->setFallbackEditor($fallback);
}
示例4: __construct
public function __construct(array $argv)
{
PhutilServiceProfiler::getInstance()->enableDiscardMode();
$original_argv = $argv;
$args = new PhutilArgumentParser($argv);
$args->setTagline('daemon overseer');
$args->setSynopsis(<<<EOHELP
**launch_daemon.php** [__options__] __daemon__
Launch and oversee an instance of __daemon__.
EOHELP
);
$args->parseStandardArguments();
$args->parsePartial(array(array('name' => 'trace-memory', 'help' => 'Enable debug memory tracing.'), array('name' => 'log', 'param' => 'file', 'help' => 'Send output to __file__.'), array('name' => 'daemonize', 'help' => 'Run in the background.'), array('name' => 'phd', 'param' => 'dir', 'help' => 'Write PID information to __dir__.'), array('name' => 'verbose', 'help' => 'Enable verbose activity logging.'), array('name' => 'load-phutil-library', 'param' => 'library', 'repeat' => true, 'help' => 'Load __library__.')));
$argv = array();
$more = $args->getUnconsumedArgumentVector();
$this->daemon = array_shift($more);
if (!$this->daemon) {
$args->printHelpAndExit();
}
if ($args->getArg('trace')) {
$this->traceMode = true;
$argv[] = '--trace';
}
if ($args->getArg('trace-memory')) {
$this->traceMode = true;
$this->traceMemory = true;
$argv[] = '--trace-memory';
}
if ($args->getArg('load-phutil-library')) {
foreach ($args->getArg('load-phutil-library') as $library) {
$argv[] = '--load-phutil-library=' . $library;
}
}
$log = $args->getArg('log');
if ($log) {
ini_set('error_log', $log);
$argv[] = '--log=' . $log;
}
$verbose = $args->getArg('verbose');
if ($verbose) {
$this->verbose = true;
$argv[] = '--verbose';
}
$this->daemonize = $args->getArg('daemonize');
$this->phddir = $args->getArg('phd');
$this->argv = $argv;
$this->moreArgs = coalesce($more, array());
error_log("Bringing daemon '{$this->daemon}' online...");
if (self::$instance) {
throw new Exception('You may not instantiate more than one Overseer per process.');
}
self::$instance = $this;
if ($this->daemonize) {
// We need to get rid of these or the daemon will hang when we TERM it
// waiting for something to read the buffers. TODO: Learn how unix works.
fclose(STDOUT);
fclose(STDERR);
ob_start();
$pid = pcntl_fork();
if ($pid === -1) {
throw new Exception('Unable to fork!');
} else {
if ($pid) {
exit(0);
}
}
}
if ($this->phddir) {
$desc = array('name' => $this->daemon, 'argv' => $this->moreArgs, 'pid' => getmypid(), 'start' => time());
Filesystem::writeFile($this->phddir . '/daemon.' . getmypid(), json_encode($desc));
}
$this->daemonID = $this->generateDaemonID();
$this->dispatchEvent(self::EVENT_DID_LAUNCH, array('argv' => array_slice($original_argv, 1), 'explicitArgv' => $this->moreArgs));
declare (ticks=1);
pcntl_signal(SIGUSR1, array($this, 'didReceiveKeepaliveSignal'));
pcntl_signal(SIGUSR2, array($this, 'didReceiveNotifySignal'));
pcntl_signal(SIGINT, array($this, 'didReceiveGracefulSignal'));
pcntl_signal(SIGTERM, array($this, 'didReceiveTerminalSignal'));
}
示例5: glx
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
require_once dirname(dirname(__FILE__)) . '/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('regenerate CSS sprite sheets');
$args->setSynopsis(<<<EOHELP
**sprites**
Rebuild CSS sprite sheets.
EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'source', 'param' => 'directory', 'help' => 'Directory with sprite sources.')));
$srcroot = $args->getArg('source');
if (!$srcroot) {
throw new Exception("You must specify a source directory with '--source'.");
}
$webroot = dirname(phutil_get_library_root('phabricator')) . '/webroot/rsrc';
$webroot = Filesystem::readablePath($webroot);
function glx($x)
{
return 60 + 48 * $x;
}
function gly($y)
示例6: commit_symbols
#!/usr/bin/env php
<?php
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setSynopsis(<<<EOSYNOPSIS
**import_project_symbols.php** [__options__] __project_name__ < symbols
Import project symbols (symbols are read from stdin).
EOSYNOPSIS
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'no-purge', 'help' => 'Do not clear all symbols for this project before ' . 'uploading new symbols. Useful for incremental updating.'), array('name' => 'ignore-errors', 'help' => 'If a line can\'t be parsed, ignore that line and ' . 'continue instead of exiting.'), array('name' => 'max-transaction', 'param' => 'num-syms', 'default' => '100000', 'help' => 'Maximum number of symbols that should ' . 'be part of a single transaction'), array('name' => 'more', 'wildcard' => true)));
$more = $args->getArg('more');
if (count($more) !== 1) {
$args->printHelpAndExit();
}
$project_name = head($more);
$project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere('name = %s', $project_name);
if (!$project) {
// TODO: Provide a less silly way to do this explicitly, or just do it right
// here.
echo "Project '{$project_name}' is unknown. Upload a diff to implicitly " . "create it.\n";
exit(1);
}
echo "Parsing input from stdin...\n";
$input = file_get_contents('php://stdin');
$input = trim($input);
$input = explode("\n", $input);
function commit_symbols($syms, $project, $no_purge)
{
示例7: __construct
public function __construct(array $argv)
{
PhutilServiceProfiler::getInstance()->enableDiscardMode();
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('daemon overseer'));
$args->setSynopsis(<<<EOHELP
**launch_daemon.php** [__options__] __daemon__
Launch and oversee an instance of __daemon__.
EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'trace-memory', 'help' => pht('Enable debug memory tracing.')), array('name' => 'verbose', 'help' => pht('Enable verbose activity logging.')), array('name' => 'label', 'short' => 'l', 'param' => 'label', 'help' => pht('Optional process label. Makes "%s" nicer, no behavioral effects.', 'ps'))));
$argv = array();
if ($args->getArg('trace')) {
$this->traceMode = true;
$argv[] = '--trace';
}
if ($args->getArg('trace-memory')) {
$this->traceMode = true;
$this->traceMemory = true;
$argv[] = '--trace-memory';
}
$verbose = $args->getArg('verbose');
if ($verbose) {
$this->verbose = true;
$argv[] = '--verbose';
}
$label = $args->getArg('label');
if ($label) {
$argv[] = '-l';
$argv[] = $label;
}
$this->argv = $argv;
if (function_exists('posix_isatty') && posix_isatty(STDIN)) {
fprintf(STDERR, pht('Reading daemon configuration from stdin...') . "\n");
}
$config = @file_get_contents('php://stdin');
$config = id(new PhutilJSONParser())->parse($config);
$this->libraries = idx($config, 'load');
$this->log = idx($config, 'log');
$this->daemonize = idx($config, 'daemonize');
$this->piddir = idx($config, 'piddir');
$this->config = $config;
if (self::$instance) {
throw new Exception(pht('You may not instantiate more than one Overseer per process.'));
}
self::$instance = $this;
$this->startEpoch = time();
// Check this before we daemonize, since if it's an issue the child will
// exit immediately.
if ($this->piddir) {
$dir = $this->piddir;
try {
Filesystem::assertWritable($dir);
} catch (Exception $ex) {
throw new Exception(pht("Specified daemon PID directory ('%s') does not exist or is " . "not writable by the daemon user!", $dir));
}
}
if (!idx($config, 'daemons')) {
throw new PhutilArgumentUsageException(pht('You must specify at least one daemon to start!'));
}
if ($this->log) {
// NOTE: Now that we're committed to daemonizing, redirect the error
// log if we have a `--log` parameter. Do this at the last moment
// so as many setup issues as possible are surfaced.
ini_set('error_log', $this->log);
}
if ($this->daemonize) {
// We need to get rid of these or the daemon will hang when we TERM it
// waiting for something to read the buffers. TODO: Learn how unix works.
fclose(STDOUT);
fclose(STDERR);
ob_start();
$pid = pcntl_fork();
if ($pid === -1) {
throw new Exception(pht('Unable to fork!'));
} else {
if ($pid) {
exit(0);
}
}
}
$this->modules = PhutilDaemonOverseerModule::getAllModules();
pcntl_signal(SIGUSR2, array($this, 'didReceiveNotifySignal'));
pcntl_signal(SIGHUP, array($this, 'didReceiveReloadSignal'));
pcntl_signal(SIGINT, array($this, 'didReceiveGracefulSignal'));
pcntl_signal(SIGTERM, array($this, 'didReceiveTerminalSignal'));
}
示例8: dirname
#!/usr/bin/env php
<?php
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('manage cache'));
$args->setSynopsis(<<<EOSYNOPSIS
**cache** __command__ [__options__]
Manage Phabricator caches.
EOSYNOPSIS
);
$args->parseStandardArguments();
$workflows = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorCacheManagementWorkflow')->loadObjects();
$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
示例9: dirname
#!/usr/bin/env php
<?php
require_once dirname(__FILE__) . '/../../__init_script__.php';
if (!posix_isatty(STDOUT)) {
$sid = posix_setsid();
if ($sid <= 0) {
throw new Exception(pht('Failed to create new process session!'));
}
}
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('daemon executor'));
$args->setSynopsis(<<<EOHELP
**exec_daemon.php** [__options__] __daemon__ ...
Run an instance of __daemon__.
EOHELP
);
$args->parse(array(array('name' => 'trace', 'help' => pht('Enable debug tracing.')), array('name' => 'trace-memory', 'help' => pht('Enable debug memory tracing.')), array('name' => 'verbose', 'help' => pht('Enable verbose activity logging.')), array('name' => 'label', 'short' => 'l', 'param' => 'label', 'help' => pht('Optional process label. Makes "%s" nicer, no behavioral effects.', 'ps')), array('name' => 'daemon', 'wildcard' => true)));
$trace_memory = $args->getArg('trace-memory');
$trace_mode = $args->getArg('trace') || $trace_memory;
$verbose = $args->getArg('verbose');
if (function_exists('posix_isatty') && posix_isatty(STDIN)) {
fprintf(STDERR, pht('Reading daemon configuration from stdin...') . "\n");
}
$config = @file_get_contents('php://stdin');
$config = id(new PhutilJSONParser())->parse($config);
PhutilTypeSpec::checkMap($config, array('log' => 'optional string|null', 'argv' => 'optional list<wild>', 'load' => 'optional list<string>', 'autoscale' => 'optional wild'));
$log = idx($config, 'log');
if ($log) {
ini_set('error_log', $log);
PhutilErrorHandler::setErrorListener(array('PhutilDaemon', 'errorListener'));
}
示例10: dirname
#!/usr/bin/env php
<?php
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setSynopsis(<<<EOSYNOPSIS
**clear_repository_symbols.php** [__options__] __repository__
Clear repository symbols.
EOSYNOPSIS
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'repository', 'wildcard' => true)));
$identifiers = $args->getArg('repository');
if (count($identifiers) !== 1) {
$args->printHelpAndExit();
}
$identifier = head($identifiers);
$repository = id(new PhabricatorRepositoryQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIdentifiers($identifiers)->executeOne();
if (!$repository) {
echo tsprintf("%s\n", pht('Repository "%s" does not exist.', $identifier));
exit(1);
}
$input = file_get_contents('php://stdin');
$normalized = array();
foreach (explode("\n", trim($input)) as $path) {
// Emulate the behavior of the symbol generation scripts.
$normalized[] = '/' . ltrim($path, './');
}
$paths = PhabricatorRepositoryCommitChangeParserWorker::lookupOrCreatePaths($normalized);
$symbol = new PhabricatorRepositorySymbol();
示例11: dirname
#!/usr/bin/env php
<?php
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('manage audits'));
$args->setSynopsis(<<<EOSYNOPSIS
**audit** __command__ [__options__]
Manage Phabricator audits.
EOSYNOPSIS
);
$args->parseStandardArguments();
$workflows = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorAuditManagementWorkflow')->execute();
$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);
示例12: dirname
#!/usr/bin/env php
<?php
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('test Filesystem::getMimeType()');
$args->setSynopsis(<<<EOHELP
**mime.php** [__options__] __file__
Determine the mime type of a file.
EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'default', 'param' => 'mimetype', 'help' => 'Use __mimetype__ as default instead of builtin default.'), array('name' => 'file', 'wildcard' => true)));
$file = $args->getArg('file');
if (count($file) !== 1) {
$args->printHelpAndExit();
}
$file = reset($file);
$default = $args->getArg('default');
if ($default) {
echo Filesystem::getMimeType($file, $default) . "\n";
} else {
echo Filesystem::getMimeType($file) . "\n";
}
示例13: dirname
#!/usr/bin/env php
<?php
require_once dirname(__FILE__) . '/__init_script__.php';
require_once dirname(__FILE__) . '/lib/PhutilLibraryMapBuilder.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline('rebuild the library map file');
$args->setSynopsis(<<<EOHELP
**phutil_rebuild_map.php** [__options__] __root__
Rebuild the library map file for a libphutil library.
EOHELP
);
$args->parseStandardArguments();
$args->parse(array(array('name' => 'quiet', 'help' => 'Do not write status messages to stderr.'), array('name' => 'drop-cache', 'help' => 'Drop the symbol cache and rebuild the entire map from ' . 'scratch.'), array('name' => 'limit', 'param' => 'N', 'default' => 8, 'help' => 'Controls the number of symbol mapper subprocesses run ' . 'at once. Defaults to 8.'), array('name' => 'show', 'help' => 'Print symbol map to stdout instead of writing it to the ' . 'map file.'), array('name' => 'ugly', 'help' => 'Use faster but less readable serialization for --show.'), array('name' => 'root', 'wildcard' => true)));
$root = $args->getArg('root');
if (count($root) !== 1) {
throw new Exception("Provide exactly one library root!");
}
$root = Filesystem::resolvePath(head($root));
$builder = new PhutilLibraryMapBuilder($root);
$builder->setQuiet($args->getArg('quiet'));
$builder->setSubprocessLimit($args->getArg('limit'));
if ($args->getArg('drop-cache')) {
$builder->dropSymbolCache();
}
if ($args->getArg('show')) {
$builder->setShowMap(true);
$builder->setUgly($args->getArg('ugly'));
}
$builder->buildMap();
exit(0);
示例14: isExecutable
#!/usr/bin/env php
<?php
require_once dirname(dirname(__FILE__)) . '/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('crazy workflow delegation'));
$args->setSynopsis(<<<EOHELP
**subworkflow.php** do echo __args__ ...
Echo some stuff using a convoluted series of delegate workflows.
EOHELP
);
// This shows how to do manual parsing of raw arguments.
final class PhutilEchoExampleArgumentWorkflow extends PhutilArgumentWorkflow
{
public function isExecutable()
{
return true;
}
public function shouldParsePartial()
{
return true;
}
public function execute(PhutilArgumentParser $args)
{
$unconsumed = $args->getUnconsumedArgumentVector();
echo implode(' ', $unconsumed) . "\n";
return 0;
}
}
// This shows how to delegate to sub-workflows.
final class PhutilDoExampleArgumentWorkflow extends PhutilArgumentWorkflow
{
示例15: dirname
#!/usr/bin/env php
<?php
$root = dirname(dirname(dirname(__FILE__)));
require_once $root . '/scripts/__init_script__.php';
$args = new PhutilArgumentParser($argv);
$args->setTagline(pht('manage lipsum'));
$args->setSynopsis(<<<EOSYNOPSIS
**lipsum** __command__ [__options__]
Manage Phabricator Test Data Generator.
EOSYNOPSIS
);
$args->parseStandardArguments();
$workflows = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorLipsumManagementWorkflow')->execute();
$workflows[] = new PhutilHelpArgumentWorkflow();
$args->parseWorkflows($workflows);