Changeset View
Changeset View
Standalone View
Standalone View
src/browse/workflow/ArcanistBrowseWorkflow.php
<?php | <?php | ||||
/** | /** | ||||
* Browse files or objects in the Phabricator web interface. | * Browse files or objects in the Phabricator web interface. | ||||
*/ | */ | ||||
final class ArcanistBrowseWorkflow extends ArcanistWorkflow { | final class ArcanistBrowseWorkflow | ||||
extends ArcanistArcWorkflow { | |||||
public function getWorkflowName() { | public function getWorkflowName() { | ||||
return 'browse'; | return 'browse'; | ||||
} | } | ||||
public function getCommandSynopses() { | public function getWorkflowInformation() { | ||||
return phutil_console_format(<<<EOTEXT | $help = pht(<<<EOTEXT | ||||
**browse** [__options__] __path__ ... | Open a file or object (like a task or revision) in a local web browser. | ||||
**browse** [__options__] __object__ ... | |||||
EOTEXT | |||||
); | |||||
} | |||||
public function getCommandHelp() { | |||||
return phutil_console_format(<<<EOTEXT | |||||
Supports: git, hg, svn | |||||
Open a file or object (like a task or revision) in your web browser. | |||||
$ arc browse README # Open a file in Diffusion. | $ arc browse README # Open a file in Diffusion. | ||||
$ arc browse T123 # View a task. | $ arc browse T123 # View a task. | ||||
$ arc browse HEAD # View a symbolic commit. | $ arc browse HEAD # View a symbolic commit. | ||||
Set the 'browser' value using 'arc set-config' to select a browser. If | To choose a browser binary to invoke, use: | ||||
no browser is set, the command will try to guess which browser to use. | |||||
$ arc set-config browser __browser-binary__ | |||||
If no browser is set, the command will try to guess which browser to use. | |||||
EOTEXT | EOTEXT | ||||
); | ); | ||||
return $this->newWorkflowInformation() | |||||
->setSynopsis(pht('Open a file or object in a local web browser.')) | |||||
->addExample('**browse** [options] -- __target__ ...') | |||||
->addExample('**browse** -- __file-name__') | |||||
->addExample('**browse** -- __object-name__') | |||||
->setHelp($help); | |||||
} | } | ||||
public function getArguments() { | public function getWorkflowArguments() { | ||||
return array( | return array( | ||||
'branch' => array( | $this->newWorkflowArgument('branch') | ||||
'param' => 'branch_name', | ->setParameter('branch-name') | ||||
'help' => pht( | ->setHelp( | ||||
pht( | |||||
'Default branch name to view on server. Defaults to "%s".', | 'Default branch name to view on server. Defaults to "%s".', | ||||
'master'), | 'master')), | ||||
), | $this->newWorkflowArgument('types') | ||||
'types' => array( | ->setParameter('type-list') | ||||
'param' => 'types', | ->setHelp( | ||||
'aliases' => array('type'), | pht( | ||||
'help' => pht( | 'Force targets to be interpreted as naming particular types of '. | ||||
'Parse arguments with particular types.'), | 'resources.')), | ||||
), | $this->newWorkflowArgument('force') | ||||
'force' => array( | ->setHelp( | ||||
'help' => pht( | pht( | ||||
'(DEPRECATED) Obsolete, use "--types path" instead.'), | '(DEPRECATED) Obsolete, use "--types path" instead.')), | ||||
), | $this->newWorkflowArgument('targets') | ||||
'*' => 'targets', | ->setIsPathArgument(true) | ||||
->setWildcard(true), | |||||
); | ); | ||||
} | } | ||||
public function desiresWorkingCopy() { | public function runWorkflow() { | ||||
return true; | |||||
} | |||||
public function desiresRepositoryAPI() { | |||||
return true; | |||||
} | |||||
public function run() { | |||||
$conduit = $this->getConduitEngine(); | |||||
$console = PhutilConsole::getConsole(); | |||||
$targets = $this->getArgument('targets'); | $targets = $this->getArgument('targets'); | ||||
$targets = array_fuse($targets); | $targets = array_fuse($targets); | ||||
if (!$targets) { | if (!$targets) { | ||||
$refs = array( | $refs = array( | ||||
new ArcanistBrowseRef(), | new ArcanistBrowseRef(), | ||||
); | ); | ||||
} else { | } else { | ||||
▲ Show 20 Lines • Show All 182 Lines • Show Last 20 Lines |