當前位置: 首頁>>代碼示例>>PHP>>正文


PHP PhutilArgumentParser::parseWorkflows方法代碼示例

本文整理匯總了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.'));
 }
開發者ID:JohnnyEstilles,項目名稱:phabricator,代碼行數:31,代碼來源:ssh-exec.php

示例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);
開發者ID:denghp,項目名稱:phabricator,代碼行數:16,代碼來源:manage_celerity.php

示例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;
開發者ID:rwray,項目名稱:libphutil,代碼行數:31,代碼來源:calculator.php

示例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()));
 }
開發者ID:pritambaral,項目名稱:libphutil,代碼行數:5,代碼來源:subworkflow.php

示例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);
開發者ID:denghp,項目名稱:phabricator,代碼行數:31,代碼來源:ssh-exec.php


注:本文中的PhutilArgumentParser::parseWorkflows方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。