2011-01-10 00:22:25 +01:00
|
|
|
<?php
|
|
|
|
|
2011-02-19 20:36:08 +01:00
|
|
|
/**
|
|
|
|
* Seduces the reader with majestic prose.
|
|
|
|
*
|
|
|
|
* @group workflow
|
|
|
|
*/
|
2012-01-31 21:07:05 +01:00
|
|
|
final class ArcanistHelpWorkflow extends ArcanistBaseWorkflow {
|
2011-01-10 00:22:25 +01:00
|
|
|
|
Make Arcanist workflow names explicit
Summary:
Currently, adding a new workflow requires you to override ArcanistConfiguration, which is messy. Instead, just load everything that extends ArcanistBaseWorkflow.
Remove all the rules tying workflow names to class names through arcane incantations.
This has a very small performance cost in that we need to load every Workflow class every time now, but we don't hit __init__ and such anymore and it was pretty negligible on my machine (98ms vs 104ms or something).
Test Plan: Ran "arc help", "arc which", "arc diff", etc.
Reviewers: edward, vrana, btrahan
Reviewed By: edward
CC: aran, zeeg
Differential Revision: https://secure.phabricator.com/D3691
2012-10-17 17:35:03 +02:00
|
|
|
public function getWorkflowName() {
|
|
|
|
return 'help';
|
|
|
|
}
|
|
|
|
|
2012-03-05 19:02:37 +01:00
|
|
|
public function getCommandSynopses() {
|
2011-01-10 00:22:25 +01:00
|
|
|
return phutil_console_format(<<<EOTEXT
|
|
|
|
**help** [__command__]
|
2012-03-05 19:02:37 +01:00
|
|
|
**help** --full
|
|
|
|
EOTEXT
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getCommandHelp() {
|
|
|
|
return phutil_console_format(<<<EOTEXT
|
2011-01-10 00:22:25 +01:00
|
|
|
Supports: english
|
|
|
|
Shows this help. With __command__, shows help about a specific
|
|
|
|
command.
|
|
|
|
EOTEXT
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getArguments() {
|
|
|
|
return array(
|
2012-03-05 19:02:37 +01:00
|
|
|
'full' => array(
|
|
|
|
'help' => 'Print detailed information about each command.',
|
|
|
|
),
|
2011-01-10 00:22:25 +01:00
|
|
|
'*' => 'command',
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function run() {
|
|
|
|
|
|
|
|
$arc_config = $this->getArcanistConfiguration();
|
|
|
|
$workflows = $arc_config->buildAllWorkflows();
|
|
|
|
ksort($workflows);
|
|
|
|
|
|
|
|
$target = null;
|
|
|
|
if ($this->getArgument('command')) {
|
2012-03-26 19:03:59 +02:00
|
|
|
$target = head($this->getArgument('command'));
|
2011-01-10 00:22:25 +01:00
|
|
|
if (empty($workflows[$target])) {
|
|
|
|
throw new ArcanistUsageException(
|
|
|
|
"Unrecognized command '{$target}'. Try 'arc help'.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$cmdref = array();
|
|
|
|
foreach ($workflows as $command => $workflow) {
|
|
|
|
if ($target && $target != $command) {
|
|
|
|
continue;
|
|
|
|
}
|
2012-03-05 19:02:37 +01:00
|
|
|
if (!$target && !$this->getArgument('full')) {
|
|
|
|
$cmdref[] = $workflow->getCommandSynopses();
|
|
|
|
continue;
|
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
$optref = array();
|
|
|
|
$arguments = $workflow->getArguments();
|
|
|
|
|
|
|
|
$config_arguments = $arc_config->getCustomArgumentsForCommand($command);
|
|
|
|
|
|
|
|
// This juggling is to put the extension arguments after the normal
|
|
|
|
// arguments, and make sure the normal arguments aren't overwritten.
|
|
|
|
ksort($arguments);
|
|
|
|
ksort($config_arguments);
|
|
|
|
foreach ($config_arguments as $argument => $spec) {
|
|
|
|
if (empty($arguments[$argument])) {
|
|
|
|
$arguments[$argument] = $spec;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach ($arguments as $argument => $spec) {
|
|
|
|
if ($argument == '*') {
|
|
|
|
continue;
|
|
|
|
}
|
'arc liberate', convenience wrapper for various libphutil operations
Summary:
The story for creating and maintaining libphutil libraries and modules
is pretty terrible right now: you need to know a bunch of secret scripts and
dark magic. Provide 'arc liberate' which endeavors to always do the right thing
and put a library in the correct state.
Test Plan:
Ran liberate on libphutil, arcanist, phabricator; created new
libphutil libraries, added classes to them, liberated everything, introduced
errors etc and liberated that stuff, nothing was obviously broken in a terrible
way..?
Reviewed By: aran
Reviewers: jungejason, tuomaspelkonen, aran
CC: aran, epriestley
Differential Revision: 269
2011-05-12 01:30:22 +02:00
|
|
|
if (!empty($spec['hide'])) {
|
|
|
|
continue;
|
|
|
|
}
|
2011-01-10 00:22:25 +01:00
|
|
|
if (isset($spec['param'])) {
|
|
|
|
if (isset($spec['short'])) {
|
|
|
|
$optref[] = phutil_console_format(
|
|
|
|
" __--%s__ __%s__, __-%s__ __%s__",
|
|
|
|
$argument,
|
|
|
|
$spec['param'],
|
|
|
|
$spec['short'],
|
|
|
|
$spec['param']);
|
|
|
|
} else {
|
|
|
|
$optref[] = phutil_console_format(
|
|
|
|
" __--%s__ __%s__",
|
|
|
|
$argument,
|
|
|
|
$spec['param']);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (isset($spec['short'])) {
|
|
|
|
$optref[] = phutil_console_format(
|
|
|
|
" __--%s__, __-%s__",
|
|
|
|
$argument,
|
|
|
|
$spec['short']);
|
|
|
|
} else {
|
|
|
|
$optref[] = phutil_console_format(
|
|
|
|
" __--%s__",
|
|
|
|
$argument);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($config_arguments[$argument])) {
|
|
|
|
$optref[] = " (This is a custom option for this ".
|
|
|
|
"project.)";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($spec['supports'])) {
|
|
|
|
$optref[] = " Supports: ".
|
|
|
|
implode(', ', $spec['supports']);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (isset($spec['help'])) {
|
|
|
|
$docs = $spec['help'];
|
|
|
|
} else {
|
|
|
|
$docs = 'This option is not documented.';
|
|
|
|
}
|
|
|
|
$docs = phutil_console_wrap($docs, 14);
|
2012-03-29 06:38:31 +02:00
|
|
|
$optref[] = "{$docs}\n";
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
if ($optref) {
|
|
|
|
$optref = implode("\n", $optref);
|
|
|
|
$optref = "\n\n".$optref;
|
|
|
|
} else {
|
|
|
|
$optref = "\n";
|
|
|
|
}
|
|
|
|
|
2012-03-05 19:02:37 +01:00
|
|
|
$cmdref[] =
|
|
|
|
$workflow->getCommandSynopses()."\n".
|
|
|
|
$workflow->getCommandHelp().
|
|
|
|
$optref;
|
2011-01-10 00:22:25 +01:00
|
|
|
}
|
|
|
|
$cmdref = implode("\n\n", $cmdref);
|
|
|
|
|
|
|
|
if ($target) {
|
|
|
|
echo "\n".$cmdref."\n";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$self = 'arc';
|
|
|
|
echo phutil_console_format(<<<EOTEXT
|
|
|
|
**NAME**
|
|
|
|
**{$self}** - arcanist, a code review and revision management utility
|
|
|
|
|
|
|
|
**SYNOPSIS**
|
|
|
|
**{$self}** __command__ [__options__] [__args__]
|
2012-03-04 12:16:45 +01:00
|
|
|
This help file provides a detailed command reference.
|
2011-01-10 00:22:25 +01:00
|
|
|
|
|
|
|
**COMMAND REFERENCE**
|
|
|
|
|
|
|
|
{$cmdref}
|
|
|
|
|
2012-03-05 19:02:37 +01:00
|
|
|
|
|
|
|
EOTEXT
|
|
|
|
);
|
|
|
|
|
|
|
|
if (!$this->getArgument('full')) {
|
2012-03-04 12:16:45 +01:00
|
|
|
echo "Run 'arc help --full' to get commands and options descriptions.\n";
|
2012-03-05 19:02:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo phutil_console_format(<<<EOTEXT
|
2011-01-10 00:22:25 +01:00
|
|
|
**OPTION REFERENCE**
|
|
|
|
|
|
|
|
__--trace__
|
|
|
|
Debugging command. Shows underlying commands as they are executed,
|
|
|
|
and full stack traces when exceptions are thrown.
|
|
|
|
|
|
|
|
__--no-ansi__
|
|
|
|
Output in plain ASCII text only, without color or style.
|
|
|
|
|
2012-06-20 21:23:45 +02:00
|
|
|
__--ansi__
|
|
|
|
Use formatting even in environments which probably don't support it.
|
2012-06-21 19:32:28 +02:00
|
|
|
Example: arc --ansi unit | less -r
|
2012-06-20 21:23:45 +02:00
|
|
|
|
2011-02-19 07:17:41 +01:00
|
|
|
__--load-phutil-library=/path/to/library__
|
|
|
|
Ignore libraries listed in .arcconfig and explicitly load specified
|
|
|
|
libraries instead. Mostly useful for Arcanist development.
|
|
|
|
|
2012-06-03 17:31:49 +02:00
|
|
|
__--conduit-uri__ __uri__
|
2011-02-19 07:17:41 +01:00
|
|
|
Ignore configured Conduit URI and use an explicit one instead. Mostly
|
|
|
|
useful for Arcanist development.
|
|
|
|
|
2012-06-03 17:31:49 +02:00
|
|
|
__--conduit-version__ __version__
|
2012-05-22 01:45:03 +02:00
|
|
|
Ignore software version and claim to be running some other version
|
|
|
|
instead. Mostly useful for Arcanist development. May cause bad things
|
|
|
|
to happen.
|
|
|
|
|
2012-06-03 17:31:49 +02:00
|
|
|
__--conduit-timeout__ __timeout__
|
|
|
|
Override the default Conduit timeout. Specified in seconds.
|
2011-01-10 00:22:25 +01:00
|
|
|
|
|
|
|
EOTEXT
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|