Changeset View
Changeset View
Standalone View
Standalone View
scripts/symbols/import_repository_symbols.php
| #!/usr/bin/env php | #!/usr/bin/env php | ||||
| <?php | <?php | ||||
| $root = dirname(dirname(dirname(__FILE__))); | $root = dirname(dirname(dirname(__FILE__))); | ||||
| require_once $root.'/scripts/__init_script__.php'; | require_once $root.'/scripts/__init_script__.php'; | ||||
| $args = new PhutilArgumentParser($argv); | $args = new PhutilArgumentParser($argv); | ||||
| $args->setSynopsis(<<<EOSYNOPSIS | $args->setSynopsis(<<<EOSYNOPSIS | ||||
| **import_repository_symbols.php** [__options__] __callsign__ < symbols | **import_repository_symbols.php** [__options__] __repository__ < symbols | ||||
| Import repository symbols (symbols are read from stdin). | Import repository symbols (symbols are read from stdin). | ||||
| EOSYNOPSIS | EOSYNOPSIS | ||||
| ); | ); | ||||
| $args->parseStandardArguments(); | $args->parseStandardArguments(); | ||||
| $args->parse( | $args->parse( | ||||
| array( | array( | ||||
| array( | array( | ||||
| Show All 12 Lines | array( | ||||
| 'name' => 'max-transaction', | 'name' => 'max-transaction', | ||||
| 'param' => 'num-syms', | 'param' => 'num-syms', | ||||
| 'default' => '100000', | 'default' => '100000', | ||||
| 'help' => pht( | 'help' => pht( | ||||
| 'Maximum number of symbols that should '. | 'Maximum number of symbols that should '. | ||||
| 'be part of a single transaction.'), | 'be part of a single transaction.'), | ||||
| ), | ), | ||||
| array( | array( | ||||
| 'name' => 'callsign', | 'name' => 'repository', | ||||
| 'wildcard' => true, | 'wildcard' => true, | ||||
| ), | ), | ||||
| )); | )); | ||||
| $callsigns = $args->getArg('callsign'); | $identifiers = $args->getArg('repository'); | ||||
| if (count($callsigns) !== 1) { | if (count($identifiers) !== 1) { | ||||
| $args->printHelpAndExit(); | $args->printHelpAndExit(); | ||||
| } | } | ||||
| $callsign = head($callsigns); | $identifier = head($identifiers); | ||||
| $repository = id(new PhabricatorRepositoryQuery()) | $repository = id(new PhabricatorRepositoryQuery()) | ||||
| ->setViewer(PhabricatorUser::getOmnipotentUser()) | ->setViewer(PhabricatorUser::getOmnipotentUser()) | ||||
| ->withCallsigns($callsigns) | ->withIdentifiers($identifiers) | ||||
| ->executeOne(); | ->executeOne(); | ||||
| if (!$repository) { | if (!$repository) { | ||||
| echo pht("Repository '%s' does not exist.", $callsign); | echo tsprintf( | ||||
| "%s\n", | |||||
| pht('Repository "%s" does not exist.', $identifier)); | |||||
| exit(1); | exit(1); | ||||
| } | } | ||||
| if (!function_exists('posix_isatty') || posix_isatty(STDIN)) { | if (!function_exists('posix_isatty') || posix_isatty(STDIN)) { | ||||
| echo pht('Parsing input from stdin...'), "\n"; | echo pht('Parsing input from stdin...'), "\n"; | ||||
| } | } | ||||
| $input = file_get_contents('php://stdin'); | $input = file_get_contents('php://stdin'); | ||||
| ▲ Show 20 Lines • Show All 166 Lines • Show Last 20 Lines | |||||