* http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * 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. */ $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline('manage open Audit requests'); $args->setSynopsis(<<<EOSYNOPSIS **audit.php** __repository_callsign__ Close all open audit requests in a repository. This is intended to reset the state of an imported repository which triggered a bunch of spurious audit requests during import. EOSYNOPSIS ); $args->parseStandardArguments(); $args->parse(array(array('name' => 'more', 'wildcard' => true))); $more = $args->getArg('more'); if (count($more) !== 1) { $args->printHelpAndExit(); } $callsign = reset($more); $repository = id(new PhabricatorRepository())->loadOneWhere('callsign = %s', $callsign); if (!$repository) { throw new Exception("No repository exists with callsign '{$callsign}'!"); } $ok = phutil_console_confirm('This will reset all open audit requests ("Audit Required" or "Concern ' . 'Raised") for commits in this repository to "Audit Not Required". This ' . 'operation destroys information and can not be undone! Are you sure ' . 'you want to proceed?');
#!/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);
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline('test InteractiveEditor class'); $args->setSynopsis(<<<EOHELP **interactive_editor.php** [__options__] Edit some content via the InteractiveEditor class. This script makes it easier to test changes to InteractiveEditor, which is difficult to unit test. EOHELP ); $args->parseStandardArguments(); $args->parse(array(array('name' => 'fallback', 'param' => 'editor', 'help' => 'Set the fallback editor.'), array('name' => 'line', 'short' => 'l', 'param' => 'number', 'help' => 'Open at line number __number__.'), array('name' => 'name', 'param' => 'filename', 'help' => 'Set edited file name.'))); if ($args->getArg('help')) { $args->printHelpAndExit(); } $editor = new PhutilInteractiveEditor("The wizard quickly\n" . "jinxed the gnomes\n" . "before they vaporized."); $name = $args->getArg('name'); if ($name) { $editor->setName($name); } $line = $args->getArg('line'); if ($line) { $editor->setLineOffset($line); } $fallback = $args->getArg('fallback'); if ($fallback) { $editor->setFallbackEditor($fallback); }
public function __construct(array $argv) { PhutilServiceProfiler::getInstance()->enableDiscardMode(); $original_argv = $argv; $args = new PhutilArgumentParser($argv); $args->setTagline('daemon overseer'); $args->setSynopsis(<<<EOHELP **launch_daemon.php** [__options__] __daemon__ Launch and oversee an instance of __daemon__. EOHELP ); $args->parseStandardArguments(); $args->parsePartial(array(array('name' => 'trace-memory', 'help' => 'Enable debug memory tracing.'), array('name' => 'log', 'param' => 'file', 'help' => 'Send output to __file__.'), array('name' => 'daemonize', 'help' => 'Run in the background.'), array('name' => 'phd', 'param' => 'dir', 'help' => 'Write PID information to __dir__.'), array('name' => 'verbose', 'help' => 'Enable verbose activity logging.'), array('name' => 'load-phutil-library', 'param' => 'library', 'repeat' => true, 'help' => 'Load __library__.'))); $argv = array(); $more = $args->getUnconsumedArgumentVector(); $this->daemon = array_shift($more); if (!$this->daemon) { $args->printHelpAndExit(); } if ($args->getArg('trace')) { $this->traceMode = true; $argv[] = '--trace'; } if ($args->getArg('trace-memory')) { $this->traceMode = true; $this->traceMemory = true; $argv[] = '--trace-memory'; } if ($args->getArg('load-phutil-library')) { foreach ($args->getArg('load-phutil-library') as $library) { $argv[] = '--load-phutil-library=' . $library; } } $log = $args->getArg('log'); if ($log) { ini_set('error_log', $log); $argv[] = '--log=' . $log; } $verbose = $args->getArg('verbose'); if ($verbose) { $this->verbose = true; $argv[] = '--verbose'; } $this->daemonize = $args->getArg('daemonize'); $this->phddir = $args->getArg('phd'); $this->argv = $argv; $this->moreArgs = coalesce($more, array()); error_log("Bringing daemon '{$this->daemon}' online..."); if (self::$instance) { throw new Exception('You may not instantiate more than one Overseer per process.'); } self::$instance = $this; if ($this->daemonize) { // We need to get rid of these or the daemon will hang when we TERM it // waiting for something to read the buffers. TODO: Learn how unix works. fclose(STDOUT); fclose(STDERR); ob_start(); $pid = pcntl_fork(); if ($pid === -1) { throw new Exception('Unable to fork!'); } else { if ($pid) { exit(0); } } } if ($this->phddir) { $desc = array('name' => $this->daemon, 'argv' => $this->moreArgs, 'pid' => getmypid(), 'start' => time()); Filesystem::writeFile($this->phddir . '/daemon.' . getmypid(), json_encode($desc)); } $this->daemonID = $this->generateDaemonID(); $this->dispatchEvent(self::EVENT_DID_LAUNCH, array('argv' => array_slice($original_argv, 1), 'explicitArgv' => $this->moreArgs)); declare (ticks=1); pcntl_signal(SIGUSR1, array($this, 'didReceiveKeepaliveSignal')); pcntl_signal(SIGUSR2, array($this, 'didReceiveNotifySignal')); pcntl_signal(SIGINT, array($this, 'didReceiveGracefulSignal')); pcntl_signal(SIGTERM, array($this, 'didReceiveTerminalSignal')); }
* You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * 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('regenerate CSS sprite sheets'); $args->setSynopsis(<<<EOHELP **sprites** Rebuild CSS sprite sheets. EOHELP ); $args->parseStandardArguments(); $args->parse(array(array('name' => 'source', 'param' => 'directory', 'help' => 'Directory with sprite sources.'))); $srcroot = $args->getArg('source'); if (!$srcroot) { throw new Exception("You must specify a source directory with '--source'."); } $webroot = dirname(phutil_get_library_root('phabricator')) . '/webroot/rsrc'; $webroot = Filesystem::readablePath($webroot); function glx($x) { return 60 + 48 * $x; } function gly($y)
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setSynopsis(<<<EOSYNOPSIS **import_project_symbols.php** [__options__] __project_name__ < symbols Import project symbols (symbols are read from stdin). EOSYNOPSIS ); $args->parseStandardArguments(); $args->parse(array(array('name' => 'no-purge', 'help' => 'Do not clear all symbols for this project before ' . 'uploading new symbols. Useful for incremental updating.'), array('name' => 'ignore-errors', 'help' => 'If a line can\'t be parsed, ignore that line and ' . 'continue instead of exiting.'), array('name' => 'max-transaction', 'param' => 'num-syms', 'default' => '100000', 'help' => 'Maximum number of symbols that should ' . 'be part of a single transaction'), array('name' => 'more', 'wildcard' => true))); $more = $args->getArg('more'); if (count($more) !== 1) { $args->printHelpAndExit(); } $project_name = head($more); $project = id(new PhabricatorRepositoryArcanistProject())->loadOneWhere('name = %s', $project_name); if (!$project) { // TODO: Provide a less silly way to do this explicitly, or just do it right // here. echo "Project '{$project_name}' is unknown. Upload a diff to implicitly " . "create it.\n"; exit(1); } echo "Parsing input from stdin...\n"; $input = file_get_contents('php://stdin'); $input = trim($input); $input = explode("\n", $input); function commit_symbols($syms, $project, $no_purge) {
public function __construct(array $argv) { PhutilServiceProfiler::getInstance()->enableDiscardMode(); $args = new PhutilArgumentParser($argv); $args->setTagline(pht('daemon overseer')); $args->setSynopsis(<<<EOHELP **launch_daemon.php** [__options__] __daemon__ Launch and oversee an instance of __daemon__. EOHELP ); $args->parseStandardArguments(); $args->parse(array(array('name' => 'trace-memory', 'help' => pht('Enable debug memory tracing.')), array('name' => 'verbose', 'help' => pht('Enable verbose activity logging.')), array('name' => 'label', 'short' => 'l', 'param' => 'label', 'help' => pht('Optional process label. Makes "%s" nicer, no behavioral effects.', 'ps')))); $argv = array(); if ($args->getArg('trace')) { $this->traceMode = true; $argv[] = '--trace'; } if ($args->getArg('trace-memory')) { $this->traceMode = true; $this->traceMemory = true; $argv[] = '--trace-memory'; } $verbose = $args->getArg('verbose'); if ($verbose) { $this->verbose = true; $argv[] = '--verbose'; } $label = $args->getArg('label'); if ($label) { $argv[] = '-l'; $argv[] = $label; } $this->argv = $argv; if (function_exists('posix_isatty') && posix_isatty(STDIN)) { fprintf(STDERR, pht('Reading daemon configuration from stdin...') . "\n"); } $config = @file_get_contents('php://stdin'); $config = id(new PhutilJSONParser())->parse($config); $this->libraries = idx($config, 'load'); $this->log = idx($config, 'log'); $this->daemonize = idx($config, 'daemonize'); $this->piddir = idx($config, 'piddir'); $this->config = $config; if (self::$instance) { throw new Exception(pht('You may not instantiate more than one Overseer per process.')); } self::$instance = $this; $this->startEpoch = time(); // Check this before we daemonize, since if it's an issue the child will // exit immediately. if ($this->piddir) { $dir = $this->piddir; try { Filesystem::assertWritable($dir); } catch (Exception $ex) { throw new Exception(pht("Specified daemon PID directory ('%s') does not exist or is " . "not writable by the daemon user!", $dir)); } } if (!idx($config, 'daemons')) { throw new PhutilArgumentUsageException(pht('You must specify at least one daemon to start!')); } if ($this->log) { // NOTE: Now that we're committed to daemonizing, redirect the error // log if we have a `--log` parameter. Do this at the last moment // so as many setup issues as possible are surfaced. ini_set('error_log', $this->log); } if ($this->daemonize) { // We need to get rid of these or the daemon will hang when we TERM it // waiting for something to read the buffers. TODO: Learn how unix works. fclose(STDOUT); fclose(STDERR); ob_start(); $pid = pcntl_fork(); if ($pid === -1) { throw new Exception(pht('Unable to fork!')); } else { if ($pid) { exit(0); } } } $this->modules = PhutilDaemonOverseerModule::getAllModules(); pcntl_signal(SIGUSR2, array($this, 'didReceiveNotifySignal')); pcntl_signal(SIGHUP, array($this, 'didReceiveReloadSignal')); pcntl_signal(SIGINT, array($this, 'didReceiveGracefulSignal')); pcntl_signal(SIGTERM, array($this, 'didReceiveTerminalSignal')); }
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline(pht('manage cache')); $args->setSynopsis(<<<EOSYNOPSIS **cache** __command__ [__options__] Manage Phabricator caches. EOSYNOPSIS ); $args->parseStandardArguments(); $workflows = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorCacheManagementWorkflow')->loadObjects(); $workflows[] = new PhutilHelpArgumentWorkflow(); $args->parseWorkflows($workflows);
#!/usr/bin/env php <?php require_once dirname(__FILE__) . '/../../__init_script__.php'; if (!posix_isatty(STDOUT)) { $sid = posix_setsid(); if ($sid <= 0) { throw new Exception(pht('Failed to create new process session!')); } } $args = new PhutilArgumentParser($argv); $args->setTagline(pht('daemon executor')); $args->setSynopsis(<<<EOHELP **exec_daemon.php** [__options__] __daemon__ ... Run an instance of __daemon__. EOHELP ); $args->parse(array(array('name' => 'trace', 'help' => pht('Enable debug tracing.')), array('name' => 'trace-memory', 'help' => pht('Enable debug memory tracing.')), array('name' => 'verbose', 'help' => pht('Enable verbose activity logging.')), array('name' => 'label', 'short' => 'l', 'param' => 'label', 'help' => pht('Optional process label. Makes "%s" nicer, no behavioral effects.', 'ps')), array('name' => 'daemon', 'wildcard' => true))); $trace_memory = $args->getArg('trace-memory'); $trace_mode = $args->getArg('trace') || $trace_memory; $verbose = $args->getArg('verbose'); if (function_exists('posix_isatty') && posix_isatty(STDIN)) { fprintf(STDERR, pht('Reading daemon configuration from stdin...') . "\n"); } $config = @file_get_contents('php://stdin'); $config = id(new PhutilJSONParser())->parse($config); PhutilTypeSpec::checkMap($config, array('log' => 'optional string|null', 'argv' => 'optional list<wild>', 'load' => 'optional list<string>', 'autoscale' => 'optional wild')); $log = idx($config, 'log'); if ($log) { ini_set('error_log', $log); PhutilErrorHandler::setErrorListener(array('PhutilDaemon', 'errorListener')); }
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setSynopsis(<<<EOSYNOPSIS **clear_repository_symbols.php** [__options__] __repository__ Clear repository symbols. EOSYNOPSIS ); $args->parseStandardArguments(); $args->parse(array(array('name' => 'repository', 'wildcard' => true))); $identifiers = $args->getArg('repository'); if (count($identifiers) !== 1) { $args->printHelpAndExit(); } $identifier = head($identifiers); $repository = id(new PhabricatorRepositoryQuery())->setViewer(PhabricatorUser::getOmnipotentUser())->withIdentifiers($identifiers)->executeOne(); if (!$repository) { echo tsprintf("%s\n", pht('Repository "%s" does not exist.', $identifier)); exit(1); } $input = file_get_contents('php://stdin'); $normalized = array(); foreach (explode("\n", trim($input)) as $path) { // Emulate the behavior of the symbol generation scripts. $normalized[] = '/' . ltrim($path, './'); } $paths = PhabricatorRepositoryCommitChangeParserWorker::lookupOrCreatePaths($normalized); $symbol = new PhabricatorRepositorySymbol();
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline(pht('manage audits')); $args->setSynopsis(<<<EOSYNOPSIS **audit** __command__ [__options__] Manage Phabricator audits. EOSYNOPSIS ); $args->parseStandardArguments(); $workflows = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorAuditManagementWorkflow')->execute(); $workflows[] = new PhutilHelpArgumentWorkflow(); $args->parseWorkflows($workflows);
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline('test Filesystem::getMimeType()'); $args->setSynopsis(<<<EOHELP **mime.php** [__options__] __file__ Determine the mime type of a file. EOHELP ); $args->parseStandardArguments(); $args->parse(array(array('name' => 'default', 'param' => 'mimetype', 'help' => 'Use __mimetype__ as default instead of builtin default.'), array('name' => 'file', 'wildcard' => true))); $file = $args->getArg('file'); if (count($file) !== 1) { $args->printHelpAndExit(); } $file = reset($file); $default = $args->getArg('default'); if ($default) { echo Filesystem::getMimeType($file, $default) . "\n"; } else { echo Filesystem::getMimeType($file) . "\n"; }
#!/usr/bin/env php <?php require_once dirname(__FILE__) . '/__init_script__.php'; require_once dirname(__FILE__) . '/lib/PhutilLibraryMapBuilder.php'; $args = new PhutilArgumentParser($argv); $args->setTagline('rebuild the library map file'); $args->setSynopsis(<<<EOHELP **phutil_rebuild_map.php** [__options__] __root__ Rebuild the library map file for a libphutil library. EOHELP ); $args->parseStandardArguments(); $args->parse(array(array('name' => 'quiet', 'help' => 'Do not write status messages to stderr.'), array('name' => 'drop-cache', 'help' => 'Drop the symbol cache and rebuild the entire map from ' . 'scratch.'), array('name' => 'limit', 'param' => 'N', 'default' => 8, 'help' => 'Controls the number of symbol mapper subprocesses run ' . 'at once. Defaults to 8.'), array('name' => 'show', 'help' => 'Print symbol map to stdout instead of writing it to the ' . 'map file.'), array('name' => 'ugly', 'help' => 'Use faster but less readable serialization for --show.'), array('name' => 'root', 'wildcard' => true))); $root = $args->getArg('root'); if (count($root) !== 1) { throw new Exception("Provide exactly one library root!"); } $root = Filesystem::resolvePath(head($root)); $builder = new PhutilLibraryMapBuilder($root); $builder->setQuiet($args->getArg('quiet')); $builder->setSubprocessLimit($args->getArg('limit')); if ($args->getArg('drop-cache')) { $builder->dropSymbolCache(); } if ($args->getArg('show')) { $builder->setShowMap(true); $builder->setUgly($args->getArg('ugly')); } $builder->buildMap(); exit(0);
#!/usr/bin/env php <?php require_once dirname(dirname(__FILE__)) . '/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline(pht('crazy workflow delegation')); $args->setSynopsis(<<<EOHELP **subworkflow.php** do echo __args__ ... Echo some stuff using a convoluted series of delegate workflows. EOHELP ); // This shows how to do manual parsing of raw arguments. final class PhutilEchoExampleArgumentWorkflow extends PhutilArgumentWorkflow { public function isExecutable() { return true; } public function shouldParsePartial() { return true; } public function execute(PhutilArgumentParser $args) { $unconsumed = $args->getUnconsumedArgumentVector(); echo implode(' ', $unconsumed) . "\n"; return 0; } } // This shows how to delegate to sub-workflows. final class PhutilDoExampleArgumentWorkflow extends PhutilArgumentWorkflow {
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline(pht('manage lipsum')); $args->setSynopsis(<<<EOSYNOPSIS **lipsum** __command__ [__options__] Manage Phabricator Test Data Generator. EOSYNOPSIS ); $args->parseStandardArguments(); $workflows = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorLipsumManagementWorkflow')->execute(); $workflows[] = new PhutilHelpArgumentWorkflow(); $args->parseWorkflows($workflows);
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline(pht('manage Phabricator storage and schemata')); $args->setSynopsis(<<<EOHELP **storage** __workflow__ [__options__] Manage Phabricator database storage and schema versioning. **storage** upgrade Initialize or upgrade Phabricator storage. **storage** upgrade --user __root__ --password __hunter2__ Use administrative credentials for schema changes. EOHELP ); $args->parseStandardArguments(); $conf = PhabricatorEnv::newObjectFromConfig('mysql.configuration-provider', array($dao = null, 'w')); $default_user = $conf->getUser(); $default_host = $conf->getHost(); $default_port = $conf->getPort(); $default_namespace = PhabricatorLiskDAO::getDefaultStorageNamespace(); try { $args->parsePartial(array(array('name' => 'force', 'short' => 'f', 'help' => pht('Do not prompt before performing dangerous operations.')), array('name' => 'user', 'short' => 'u', 'param' => 'username', 'default' => $default_user, 'help' => pht("Connect with __username__ instead of the configured default ('%s').", $default_user)), array('name' => 'password', 'short' => 'p', 'param' => 'password', 'help' => pht('Use __password__ instead of the configured default.')), array('name' => 'namespace', 'param' => 'name', 'default' => $default_namespace, 'help' => pht("Use namespace __namespace__ instead of the configured " . "default ('%s'). This is an advanced feature used by unit tests; " . "you should not normally use this flag.", $default_namespace)), array('name' => 'dryrun', 'help' => pht('Do not actually change anything, just show what would be changed.')), array('name' => 'disable-utf8mb4', 'help' => pht('Disable utf8mb4, even if the database supports it. This is an ' . 'advanced feature used for testing changes to Phabricator; you ' . 'should not normally use this flag.')))); } catch (PhutilArgumentUsageException $ex) { $args->printUsageException($ex); exit(77); } // First, test that the Phabricator configuration is set up correctly. After // we know this works we'll test any administrative credentials specifically.
#!/usr/bin/env php <?php require_once dirname(__FILE__) . '/../__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline(pht('test context-free grammars')); $args->setSynopsis(<<<EOHELP **lipsum.php** __class__ Generate output from a named context-free grammar. EOHELP ); $args->parseStandardArguments(); $args->parse(array(array('name' => 'class', 'wildcard' => true))); $class = $args->getArg('class'); if (count($class) !== 1) { $args->printHelpAndExit(); } $class = reset($class); $symbols = id(new PhutilClassMapQuery())->setAncestorClass('PhutilContextFreeGrammar')->execute(); $symbols = ipull($symbols, 'name', 'name'); if (empty($symbols[$class])) { $available = implode(', ', array_keys($symbols)); throw new PhutilArgumentUsageException(pht("Class '%s' is not a defined, concrete subclass of %s. " . "Available classes are: %s", $class, 'PhutilContextFreeGrammar', $available)); } $object = newv($class, array()); echo $object->generate() . "\n";
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline(pht('manage SMS')); $args->setSynopsis(<<<EOSYNOPSIS **sms** __command__ [__options__] Manage Phabricator SMS stuff. EOSYNOPSIS ); $args->parseStandardArguments(); $workflows = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorSMSManagementWorkflow')->execute(); $workflows[] = new PhutilHelpArgumentWorkflow(); $args->parseWorkflows($workflows);
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline(pht('manage garbage colletors')); $args->setSynopsis(<<<EOSYNOPSIS **garbage** __command__ [__options__] Manage garbage collectors. EOSYNOPSIS ); $args->parseStandardArguments(); $workflows = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorGarbageCollectorManagementWorkflow')->execute(); $workflows[] = new PhutilHelpArgumentWorkflow(); $args->parseWorkflows($workflows);
#!/usr/bin/env php <?php /* * 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. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * 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. */ $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline('manage fact configuration'); $args->setSynopsis(<<<EOSYNOPSIS **fact** __command__ [__options__] Manage and debug Phabricator data extraction, storage and configuration used to compute statistics. EOSYNOPSIS ); $args->parseStandardArguments(); $workflows = array(new PhabricatorFactManagementDestroyWorkflow(), new PhabricatorFactManagementAnalyzeWorkflow(), new PhabricatorFactManagementStatusWorkflow(), new PhabricatorFactManagementListWorkflow(), new PhabricatorFactManagementCursorsWorkflow(), new PhutilHelpArgumentWorkflow()); $args->parseWorkflows($workflows);
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline('manage authentication'); $args->setSynopsis(<<<EOSYNOPSIS **auth** __command__ [__options__] Manage Phabricator authentication configuration. EOSYNOPSIS ); $args->parseStandardArguments(); $workflows = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorAuthManagementWorkflow')->loadObjects(); $workflows[] = new PhutilHelpArgumentWorkflow(); $args->parseWorkflows($workflows);
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline(pht('manage internationalization')); $args->setSynopsis(<<<EOSYNOPSIS **i18n** __command__ [__options__] Manage translations and internationalization. EOSYNOPSIS ); $args->parseStandardArguments(); $workflows = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorInternationalizationManagementWorkflow')->loadObjects(); $workflows[] = new PhutilHelpArgumentWorkflow(); $args->parseWorkflows($workflows);
* you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * 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. */ $package_spec = array('javelin.pkg.js' => array('javelin-util', 'javelin-install', 'javelin-event', 'javelin-stratcom', 'javelin-behavior', 'javelin-request', 'javelin-vector', 'javelin-dom', 'javelin-json', 'javelin-uri'), 'typeahead.pkg.js' => array('javelin-typeahead', 'javelin-typeahead-normalizer', 'javelin-typeahead-source', 'javelin-typeahead-preloaded-source', 'javelin-typeahead-ondemand-source', 'javelin-tokenizer', 'javelin-behavior-aphront-basic-tokenizer'), 'core.pkg.js' => array('javelin-mask', 'javelin-workflow', 'javelin-behavior-workflow', 'javelin-behavior-aphront-form-disable-on-submit', 'phabricator-keyboard-shortcut-manager', 'phabricator-keyboard-shortcut', 'javelin-behavior-phabricator-keyboard-shortcuts', 'javelin-behavior-refresh-csrf', 'javelin-behavior-phabricator-watch-anchor', 'javelin-behavior-phabricator-autofocus', 'phabricator-paste-file-upload', 'phabricator-menu-item', 'phabricator-dropdown-menu', 'javelin-behavior-phabricator-oncopy', 'phabricator-tooltip', 'javelin-behavior-phabricator-tooltips', 'phabricator-prefab'), 'core.pkg.css' => array('phabricator-core-css', 'phabricator-core-buttons-css', 'phabricator-standard-page-view', 'aphront-dialog-view-css', 'aphront-form-view-css', 'aphront-panel-view-css', 'aphront-side-nav-view-css', 'aphront-table-view-css', 'aphront-crumbs-view-css', 'aphront-tokenizer-control-css', 'aphront-typeahead-control-css', 'aphront-list-filter-view-css', 'phabricator-directory-css', 'phabricator-jump-nav', 'phabricator-app-buttons-css', 'phabricator-remarkup-css', 'syntax-highlighting-css', 'aphront-pager-view-css', 'phabricator-transaction-view-css', 'aphront-tooltip-css', 'aphront-headsup-view-css', 'phabricator-flag-css', 'aphront-error-view-css'), 'differential.pkg.css' => array('differential-core-view-css', 'differential-changeset-view-css', 'differential-results-table-css', 'differential-revision-history-css', 'differential-table-of-contents-css', 'differential-revision-comment-css', 'differential-revision-add-comment-css', 'differential-revision-comment-list-css', 'phabricator-object-selector-css', 'aphront-headsup-action-list-view-css', 'phabricator-content-source-view-css', 'differential-local-commits-view-css', 'inline-comment-summary-css'), 'differential.pkg.js' => array('phabricator-drag-and-drop-file-upload', 'phabricator-shaped-request', 'javelin-behavior-differential-feedback-preview', 'javelin-behavior-differential-edit-inline-comments', 'javelin-behavior-differential-populate', 'javelin-behavior-differential-show-more', 'javelin-behavior-differential-diff-radios', 'javelin-behavior-differential-accept-with-errors', 'javelin-behavior-differential-comment-jump', 'javelin-behavior-differential-add-reviewers-and-ccs', 'javelin-behavior-differential-keyboard-navigation', 'javelin-behavior-aphront-drag-and-drop', 'javelin-behavior-aphront-drag-and-drop-textarea', 'javelin-behavior-phabricator-object-selector', 'javelin-behavior-repository-crossreference', 'differential-inline-comment-editor', 'javelin-behavior-differential-dropdown-menus', 'javelin-behavior-buoyant'), 'diffusion.pkg.css' => array('diffusion-commit-view-css', 'diffusion-icons-css'), 'diffusion.pkg.js' => array('javelin-behavior-diffusion-pull-lastmodified', 'javelin-behavior-diffusion-commit-graph', 'javelin-behavior-audit-preview'), 'maniphest.pkg.css' => array('maniphest-task-summary-css', 'maniphest-transaction-detail-css', 'aphront-attached-file-view-css', 'phabricator-project-tag-css'), 'maniphest.pkg.js' => array('javelin-behavior-maniphest-batch-selector', 'javelin-behavior-maniphest-transaction-controls', 'javelin-behavior-maniphest-transaction-preview', 'javelin-behavior-maniphest-transaction-expand', 'javelin-behavior-maniphest-subpriority-editor')); require_once dirname(__FILE__) . '/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline('map static resources'); $args->setSynopsis("**celerity_mapper.php** [--output __path__] [--with-custom] <webroot>"); $args->parse(array(array('name' => 'output', 'param' => 'path', 'default' => '../src/__celerity_resource_map__.php', 'help' => "Set the path for resource map. It is usually useful for " . "'celerity.resource-path' configuration."), array('name' => 'with-custom', 'help' => 'Include resources in <webroot>/rsrc/custom/.'), array('name' => 'webroot', 'wildcard' => true))); $root = $args->getArg('webroot'); if (count($root) != 1 || !is_dir(reset($root))) { $args->printHelpAndExit(); } $root = Filesystem::resolvePath(reset($root)); $celerity_path = Filesystem::resolvePath($args->getArg('output'), $root); $with_custom = $args->getArg('with-custom'); $resource_hash = PhabricatorEnv::getEnvConfig('celerity.resource-hash'); $runtime_map = array(); echo "Finding raw static resources...\n"; $finder = id(new FileFinder($root))->withType('f')->withSuffix('png')->withSuffix('jpg')->withSuffix('gif')->withSuffix('swf')->withFollowSymlinks(true)->setGenerateChecksums(true); if (!$with_custom) { $finder->excludePath('./rsrc/custom'); }
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline('manage hunks'); $args->setSynopsis(<<<EOSYNOPSIS **hunks** __command__ [__options__] Manage Differential hunk storage. EOSYNOPSIS ); $args->parseStandardArguments(); $workflows = id(new PhutilSymbolLoader())->setAncestorClass('PhabricatorHunksManagementWorkflow')->loadObjects(); $workflows[] = new PhutilHelpArgumentWorkflow(); $args->parseWorkflows($workflows);
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(dirname(__FILE__)))); require_once $root . '/scripts/__init_script__.php'; PhabricatorAphlictManagementWorkflow::requireExtensions(); $args = new PhutilArgumentParser($argv); $args->setTagline(pht('manage Aphlict notification server')); $args->setSynopsis(<<<EOSYNOPSIS **aphlict** __command__ [__options__] Manage the Aphlict server. EOSYNOPSIS ); $args->parseStandardArguments(); $workflows = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorAphlictManagementWorkflow')->execute(); $workflows[] = new PhutilHelpArgumentWorkflow(); $args->parseWorkflows($workflows);
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline(pht('load files as image macros')); $args->setSynopsis(<<<EOHELP **add_macro.php** __image__ [--as __name__] Add an image macro. This can be useful for importing a large number of macros. EOHELP ); $args->parseStandardArguments(); $args->parse(array(array('name' => 'as', 'param' => 'name', 'help' => pht('Use a specific name instead of the first part of the image name.')), array('name' => 'more', 'wildcard' => true))); $more = $args->getArg('more'); if (count($more) !== 1) { $args->printHelpAndExit(); } $path = head($more); $data = Filesystem::readFile($path); $name = $args->getArg('as'); if ($name === null) { $name = head(explode('.', basename($path))); } $existing = id(new PhabricatorFileImageMacro())->loadOneWhere('name = %s', $name); if ($existing) { throw new Exception(pht("A macro already exists with the name '%s'!", $name)); } $file = PhabricatorFile::newFromFileData($data, array('name' => basename($path), 'canCDN' => true)); $macro = id(new PhabricatorFileImageMacro())->setFilePHID($file->getPHID())->setName($name)->save(); $id = $file->getID();
#!/usr/bin/env php <?php $ssh_start_time = microtime(true); $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $ssh_log = PhabricatorSSHLog::getLog(); $args = new PhutilArgumentParser($argv); $args->setTagline(pht('execute SSH requests')); $args->setSynopsis(<<<EOSYNOPSIS **ssh-exec** --phabricator-ssh-user __user__ [--ssh-command __commmand__] **ssh-exec** --phabricator-ssh-device __device__ [--ssh-command __commmand__] Execute authenticated SSH requests. This script is normally invoked via SSHD, but can be invoked manually for testing. EOSYNOPSIS ); $args->parseStandardArguments(); $args->parse(array(array('name' => 'phabricator-ssh-user', 'param' => 'username', 'help' => pht('If the request authenticated with a user key, the name of the ' . 'user.')), array('name' => 'phabricator-ssh-device', 'param' => 'name', 'help' => pht('If the request authenticated with a device key, the name of the ' . 'device.')), array('name' => 'phabricator-ssh-key', 'param' => 'id', 'help' => pht('The ID of the SSH key which authenticated this request. This is ' . 'used to allow logs to report when specific keys were used, to make ' . 'it easier to manage credentials.')), array('name' => 'ssh-command', 'param' => 'command', 'help' => pht('Provide a command to execute. This makes testing this script ' . 'easier. When running normally, the command is read from the ' . 'environment (%s), which is populated by sshd.', 'SSH_ORIGINAL_COMMAND')))); try { $remote_address = null; $ssh_client = getenv('SSH_CLIENT'); if ($ssh_client) { // This has the format "<ip> <remote-port> <local-port>". Grab the IP. $remote_address = head(explode(' ', $ssh_client)); $ssh_log->setData(array('r' => $remote_address)); } $key_id = $args->getArg('phabricator-ssh-key'); if ($key_id) { $ssh_log->setData(array('k' => $key_id)); } $user_name = $args->getArg('phabricator-ssh-user');
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline(pht('manage policies')); $args->setSynopsis(<<<EOSYNOPSIS **policy** __command__ [__options__] Administrative tool for reviewing and editing policies. EOSYNOPSIS ); $args->parseStandardArguments(); $workflows = id(new PhutilClassMapQuery())->setAncestorClass('PhabricatorPolicyManagementWorkflow')->execute(); $workflows[] = new PhutilHelpArgumentWorkflow(); $args->parseWorkflows($workflows);
#!/usr/bin/env php <?php $root = dirname(dirname(dirname(__FILE__))); require_once $root . '/scripts/__init_script__.php'; $args = new PhutilArgumentParser($argv); $args->setTagline(pht('emit a test event')); $args->setSynopsis(<<<EOHELP **emit_test_event.php** [--listen listener] ... Emit a test event after installing any specified __listener__s. EOHELP ); $args->parseStandardArguments(); $args->parse(array(array('name' => 'listen', 'param' => 'listener', 'repeat' => true))); $console = PhutilConsole::getConsole(); foreach ($args->getArg('listen') as $listener) { $console->writeOut("%s\n", pht("Installing '%s'...", $listener)); newv($listener, array())->register(); } $console->writeOut("%s\n", pht('Emitting event...')); PhutilEventEngine::dispatchEvent(new PhabricatorEvent(PhabricatorEventType::TYPE_TEST_DIDRUNTEST, array('time' => time()))); $console->writeOut("%s\n", pht('Done.')); exit(0);
* You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * 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); }