*/
$include_path = ini_get('include_path');
-ini_set('include_path', $include_path.':'.dirname(__FILE__).'/../../');
+
+$parent_dir = dirname(dirname(dirname(__FILE__)));
+
+ini_set('include_path', $include_path.PATH_SEPARATOR.$parent_dir);
@include_once 'libphutil/src/__phutil_library_init__.php';
if (!@constant('__LIBPHUTIL__')) {
echo "ERROR: Unable to load libphutil. Update your PHP 'include_path' to ".
exit(1);
}
-phutil_load_library(dirname(__FILE__).'/../src/');
+phutil_load_library(dirname(dirname(__FILE__)).'/src/');
// There may be some kind of auto-prepend script configured which starts an
// output buffer. Discard any such output buffers.
"'{$min_version}'.");
}
- $need_functions = array(
- 'json_decode' => '--without-json',
- );
+ // NOTE: We don't have phutil_is_windows() yet here.
+
+ if (DIRECTORY_SEPARATOR != '/') {
+ $need_functions = array(
+ 'curl_init' => array('builtin-dll', 'php_curl.dll'),
+ );
+ } else {
+ $need_functions = array(
+ 'json_decode' => array('flag', '--without-json'),
+ );
+ }
$problems = array();
$config = null;
$show_config = false;
- foreach ($need_functions as $fname => $flag) {
+ foreach ($need_functions as $fname => $resolution) {
if (function_exists($fname)) {
continue;
}
}
}
- if (strpos($config, $flag) !== false) {
+ $generic = true;
+ list($what, $which) = $resolution;
+
+ if ($what == 'flag' && strpos($config, $which) !== false) {
$show_config = true;
+ $generic = false;
$problems[] =
- "This build of PHP was compiled with the configure flag '{$flag}', ".
+ "This build of PHP was compiled with the configure flag '{$which}', ".
"which means it does not have the function '{$fname}()'. This ".
"function is required for arc to run. Rebuild PHP without this flag. ".
"You may also be able to build or install the relevant extension ".
"separately.";
- } else {
+ }
+
+ if ($what == 'builtin-dll') {
+ $generic = false;
+ $problems[] =
+ "Your install of PHP does not have the '{$which}' extension enabled. ".
+ "Edit your php.ini file and uncomment the line which reads ".
+ "'extension={$which}'.";
+ }
+
+ if ($generic) {
$problems[] =
"This build of PHP is missing the required function '{$fname}()'. ".
"Rebuild PHP or install the extension which provides '{$fname}()'.";
'print' => true,
'exit' => true,
'die' => true,
- 'phutil_load_library' => true,
+ 'phutil_is_windows' => true,
// HPHP/i defines these functions as 'internal', but they are NOT
// builtins and do not exist in vanilla PHP. Make sure we don't mark them
*/
final class ArcanistAliasWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**alias**
**alias** __command__
**alias** __command__ __target__ -- [__options__]
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: cli
Create an alias from __command__ to __target__ (optionally, with
__options__). For example:
arc alias fpatch
Without any arguments, 'arc alias' will list aliases.
-
EOTEXT
);
}
*/
final class ArcanistAmendWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**amend** [--revision __revision_id__] [--show]
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: git
Amend the working copy after a revision has been accepted, so commits
can be marked 'committed' and pushed upstream.
return $this->arcanistConfiguration;
}
+ public function getCommandSynopses() {
+ return get_class($this).": Undocumented";
+ }
+
public function getCommandHelp() {
return get_class($this).": Undocumented";
}
}
public static function getUserConfigurationFileLocation() {
- return getenv('HOME').'/.arcrc';
+ if (phutil_is_windows()) {
+ return getenv('APPDATA').'/.arcrc';
+ } else {
+ return getenv('HOME').'/.arcrc';
+ }
}
public static function readUserConfigurationFile() {
$user_config = array();
$user_config_path = self::getUserConfigurationFileLocation();
if (Filesystem::pathExists($user_config_path)) {
- $mode = fileperms($user_config_path);
- if (!$mode) {
- throw new Exception("Unable to get perms of '{$user_config_path}'!");
- }
- if ($mode & 0177) {
- // Mode should allow only owner access.
- $prompt = "File permissions on your ~/.arcrc are too open. ".
- "Fix them by chmod'ing to 600?";
- if (!phutil_console_confirm($prompt, $default_no = false)) {
- throw new ArcanistUsageException("Set ~/.arcrc to file mode 600.");
+
+ if (!phutil_is_windows()) {
+ $mode = fileperms($user_config_path);
+ if (!$mode) {
+ throw new Exception("Unable to get perms of '{$user_config_path}'!");
+ }
+ if ($mode & 0177) {
+ // Mode should allow only owner access.
+ $prompt = "File permissions on your ~/.arcrc are too open. ".
+ "Fix them by chmod'ing to 600?";
+ if (!phutil_console_confirm($prompt, $default_no = false)) {
+ throw new ArcanistUsageException("Set ~/.arcrc to file mode 600.");
+ }
+ execx('chmod 600 %s', $user_config_path);
}
- execx('chmod 600 %s', $user_config_path);
}
$user_config_data = Filesystem::readFile($user_config_path);
$path = self::getUserConfigurationFileLocation();
Filesystem::writeFile($path, $json);
- execx('chmod 600 %s', $path);
+
+ if (!phutil_is_windows()) {
+ execx('chmod 600 %s', $path);
+ }
}
private $branches;
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**branch**
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: git
A wrapper on 'git branch'. It pulls data from Differential and
displays the revision status next to the branch name.
*/
final class ArcanistCallConduitWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**call-conduit** __method__
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: http, https
Allows you to make a raw Conduit method call:
$ echo '{}' | arc call-conduit conduit.ping
$ echo '{"phid":"PHID-FILE-xxxx"}' | arc call-conduit file.download
-
EOTEXT
);
}
private $revisionID;
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**commit** [--revision __revision_id__] [--show]
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: svn
Commit a revision which has been accepted by a reviewer.
EOTEXT
*/
final class ArcanistCoverWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**cover**
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: svn, git
Cover your... professional reputation. Show blame for the lines you
changed in your working copy. This will take a minute because blame
private $revisionID;
private $unitWorkflow;
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**diff** [__paths__] (svn)
**diff** [__commit__] (git, hg)
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: git, svn, hg
Generate a Differential diff or revision from local changes.
Under svn, you can choose to include only some of the modified files
in the working copy in the diff by specifying their paths. If you
omit paths, all changes are included in the diff.
-
EOTEXT
);
}
private $saveAs;
private $show;
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**download** __file__ [--as __name__] [--show]
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: filesystems
Download a file to local disk, e.g.:
$ arc download F33 # Download file 'F33'
-
EOTEXT
);
}
private $sourceID;
private $format;
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**export** [__paths__] __format__ (svn)
**export** [__commit_range__] __format__ (git)
**export** __--revision__ __revision_id__ __format__
**export** __--diff__ __diff_id__ __format__
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: git, svn
Export the local changeset (or a Differential changeset) to a file,
in some __format__: git diff (__--git__), unified diff
*/
final class ArcanistGitHookPreReceiveWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**git-hook-pre-receive**
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: git
You can install this as a git pre-receive hook.
EOTEXT
*/
final class ArcanistHelpWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**help** [__command__]
+ **help** --full
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: english
Shows this help. With __command__, shows help about a specific
command.
public function getArguments() {
return array(
+ 'full' => array(
+ 'help' => 'Print detailed information about each command.',
+ ),
'*' => 'command',
);
}
if ($target && $target != $command) {
continue;
}
+ if (!$target && !$this->getArgument('full')) {
+ $cmdref[] = $workflow->getCommandSynopses();
+ continue;
+ }
$optref = array();
$arguments = $workflow->getArguments();
$optref = "\n";
}
- $cmdref[] = $workflow->getCommandHelp().$optref;
+ $cmdref[] =
+ $workflow->getCommandSynopses()."\n".
+ $workflow->getCommandHelp().
+ $optref;
}
$cmdref = implode("\n\n", $cmdref);
}
$self = 'arc';
+ $description = ($this->getArgument('full') ?
+ "This help file provides a detailed command reference." :
+ "Run 'arc help --full' to get detailed command reference.");
echo phutil_console_format(<<<EOTEXT
**NAME**
**{$self}** - arcanist, a code review and revision management utility
**SYNOPSIS**
**{$self}** __command__ [__options__] [__args__]
-
- This help file provides a detailed command reference.
+ {$description}
**COMMAND REFERENCE**
{$cmdref}
+
+EOTEXT
+ );
+
+ if (!$this->getArgument('full')) {
+ return;
+ }
+
+ echo phutil_console_format(<<<EOTEXT
**OPTION REFERENCE**
__--trace__
*/
final class ArcanistInstallCertificateWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**install-certificate** [uri]
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: http, https
Installs Conduit credentials into your ~/.arcrc for the given install
of Phabricator. You need to do this before you can use 'arc', as it
*/
final class ArcanistLandWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**land** [__options__] __branch__ [--onto __master__]
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: git
Land an accepted change (currently sitting in local feature branch
immutable repositories (or when --merge is provided), it will perform
a --no-ff merge (the branch will always be merged into __master__ with
a merge commit).
-
EOTEXT
);
}
*/
final class ArcanistLiberateWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**liberate** [__path__]
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: libphutil
Create or update a libphutil library, generating required metadata
files like \__init__.php.
return $this;
}
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**lint** [__options__] [__paths__]
**lint** [__options__] --rev [__rev__]
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: git, svn, hg
Run static analysis on changes to check for mistakes. If no files
are specified, lint will be run on all files which have been modified.
*/
final class ArcanistListWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**list**
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: git, svn, hg
List your open Differential revisions.
EOTEXT
*/
final class ArcanistMarkCommittedWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**mark-committed** __revision__
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: git, svn
Manually mark a revision as committed. You should not normally need
to do this; arc commit (svn), arc amend (git), arc merge (git, hg) or
*/
final class ArcanistMergeWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**merge**
- Deprecated.
+EOTEXT
+ );
+ }
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
+ Deprecated.
EOTEXT
);
}
<?php
/*
- * Copyright 2011 Facebook, Inc.
+ * Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private $title;
private $json;
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**paste** [--title __title__] [--lang __language__] [--json]
**paste** __id__ [--json]
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: text
Share and grab text using the Paste application. To create a paste,
use stdin to provide the text:
To retrieve a paste, specify the paste ID:
$ arc paste P123
-
EOTEXT
);
}
private $source;
private $sourceParam;
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**patch** __D12345__
**patch** __--revision__ __revision_id__
**patch** __--diff__ __diff_id__
**patch** __--patch__ __file__
**patch** __--arcbundle__ __bundlefile__
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: git, svn, hg
Apply the changes in a Differential revision, patchfile, or arc
bundle to the working copy.
*/
final class ArcanistShellCompleteWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**shell-complete** __--current__ __N__ -- [__argv__]
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: bash, etc.
Implements shell completion. To use shell completion, source the
appropriate script from 'resources/shell/' in your .shellrc.
*/
final class ArcanistSvnHookPreCommitWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**svn-hook-pre-commit** __repository__ __transaction__
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: svn
You can install this as an SVN pre-commit hook. For more information,
see the article "Installing Arcanist SVN Hooks" in the Arcanist
private $testResults;
private $engine;
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**unit** [__options__] [__paths__]
**unit** [__options__] --rev [__rev__]
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: git, svn, hg
Run unit tests that cover specified paths. If no paths are specified,
unit tests covering all modified files will be run.
<?php
/*
- * Copyright 2011 Facebook, Inc.
+ * Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
private $paths;
private $json;
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**upload** __file__ [__file__ ...] [--json]
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: filesystems
Upload a file from local disk.
-
EOTEXT
);
}
*/
final class ArcanistWhichWorkflow extends ArcanistBaseWorkflow {
- public function getCommandHelp() {
+ public function getCommandSynopses() {
return phutil_console_format(<<<EOTEXT
**which** (svn)
**which** [commit] (hg, git)
+EOTEXT
+ );
+ }
+
+ public function getCommandHelp() {
+ return phutil_console_format(<<<EOTEXT
Supports: svn, git, hg
Shows which revision is in the working copy (or which revisions, if
more than one matches).