本文整理汇总了PHP中PhutilArgumentParser::parseWorkflows方法的典型用法代码示例。如果您正苦于以下问题:PHP PhutilArgumentParser::parseWorkflows方法的具体用法?PHP PhutilArgumentParser::parseWorkflows怎么用?PHP PhutilArgumentParser::parseWorkflows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhutilArgumentParser
的用法示例。
在下文中一共展示了PhutilArgumentParser::parseWorkflows方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: id
$workflows = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorSSHWorkflow')->loadObjects();
$workflow_names = mpull($workflows, 'getName', 'getName');
if (!$original_argv) {
throw new Exception(pht("Welcome to Phabricator.\n\n" . "You are logged in as %s.\n\n" . "You haven't specified a command to run. This means you're requesting " . "an interactive shell, but Phabricator does not provide an " . "interactive shell over SSH.\n\n" . "Usually, you should run a command like `%s` or `%s` " . "rather than connecting directly with SSH.\n\n" . "Supported commands are: %s.", $user->getUsername(), 'git clone', 'hg push', implode(', ', $workflow_names)));
}
$log_argv = implode(' ', $original_argv);
$log_argv = id(new PhutilUTF8StringTruncator())->setMaximumCodepoints(128)->truncateString($log_argv);
$ssh_log->setData(array('C' => $original_argv[0], 'U' => $log_argv));
$command = head($original_argv);
$parseable_argv = $original_argv;
array_unshift($parseable_argv, 'phabricator-ssh-exec');
$parsed_args = new PhutilArgumentParser($parseable_argv);
if (empty($workflow_names[$command])) {
throw new Exception(pht('Invalid command.'));
}
$workflow = $parsed_args->parseWorkflows($workflows);
$workflow->setUser($user);
$workflow->setOriginalArguments($original_argv);
$workflow->setIsClusterRequest($is_cluster_request);
$sock_stdin = fopen('php://stdin', 'r');
if (!$sock_stdin) {
throw new Exception(pht('Unable to open stdin.'));
}
$sock_stdout = fopen('php://stdout', 'w');
if (!$sock_stdout) {
throw new Exception(pht('Unable to open stdout.'));
}
$sock_stderr = fopen('php://stderr', 'w');
if (!$sock_stderr) {
throw new Exception(pht('Unable to open stderr.'));
}
示例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
* 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('simple calculator example');
$args->setSynopsis(<<<EOHELP
**calculator.php** __op__ __n__ ...
Perform a calculation.
EOHELP
);
$add_workflow = id(new PhutilArgumentWorkflow())->setName('add')->setExamples('**add** __n__ ...')->setSynopsis('Compute the sum of a list of numbers.')->setArguments(array(array('name' => 'numbers', 'wildcard' => true)));
$mul_workflow = id(new PhutilArgumentWorkflow())->setName('mul')->setExamples('**mul** __n__ ...')->setSynopsis('Compute the product of a list of numbers.')->setArguments(array(array('name' => 'numbers', 'wildcard' => true)));
$flow = $args->parseWorkflows(array($add_workflow, $mul_workflow, new PhutilHelpArgumentWorkflow()));
$nums = $args->getArg('numbers');
if (empty($nums)) {
echo "You must provide one or more numbers!\n";
exit(1);
}
foreach ($nums as $num) {
if (!is_numeric($num)) {
echo "Number '{$num}' is not numeric!\n";
exit(1);
}
}
switch ($flow->getName()) {
case 'add':
echo array_sum($nums) . "\n";
break;
示例4: execute
public function execute(PhutilArgumentParser $args)
{
$echo_workflow = id(new PhutilEchoExampleArgumentWorkflow())->setName('echo')->setExamples('**echo** __string__ ...')->setSynopsis(pht('Echo __string__.'));
$args->parseWorkflows(array($echo_workflow, new PhutilHelpArgumentWorkflow()));
}
示例5: mpull
$workflow_names = mpull($workflows, 'getName', 'getName');
// Now, rebuild the original command.
$original_argv = id(new PhutilShellLexer())->splitArguments($original_command);
if (!$original_argv) {
throw new Exception(pht("Welcome to Phabricator.\n\n" . "You are logged in as %s.\n\n" . "You haven't specified a command to run. This means you're requesting " . "an interactive shell, but Phabricator does not provide an " . "interactive shell over SSH.\n\n" . "Usually, you should run a command like `git clone` or `hg push` " . "rather than connecting directly with SSH.\n\n" . "Supported commands are: %s.", $user->getUsername(), implode(', ', $workflow_names)));
}
$log_argv = implode(' ', array_slice($original_argv, 1));
$log_argv = id(new PhutilUTF8StringTruncator())->setMaximumCodepoints(128)->truncateString($log_argv);
$ssh_log->setData(array('C' => $original_argv[0], 'U' => $log_argv));
$command = head($original_argv);
array_unshift($original_argv, 'phabricator-ssh-exec');
$original_args = new PhutilArgumentParser($original_argv);
if (empty($workflow_names[$command])) {
throw new Exception('Invalid command.');
}
$workflow = $original_args->parseWorkflows($workflows);
$workflow->setUser($user);
$sock_stdin = fopen('php://stdin', 'r');
if (!$sock_stdin) {
throw new Exception('Unable to open stdin.');
}
$sock_stdout = fopen('php://stdout', 'w');
if (!$sock_stdout) {
throw new Exception('Unable to open stdout.');
}
$sock_stderr = fopen('php://stderr', 'w');
if (!$sock_stderr) {
throw new Exception('Unable to open stderr.');
}
$socket_channel = new PhutilSocketChannel($sock_stdin, $sock_stdout);
$error_channel = new PhutilSocketChannel(null, $sock_stderr);