public function parse($argv) { if ($this->isInValidArgv($argv)) { throw new \InvalidArgumentException("Invalid argv"); } // en cas d'erreur de chargement de la classe, ajouter manuellement //'Garden\\Cli\\' => array($vendorDir . '/vanilla/garden-cli/src'), // au fichier vendor/composer/autoload_psr4.php $cli = new Cli(); $cli->opt('config:c', 'path/to/configuration/file', true)->command("connect")->description('run connector')->opt('id:i', 'connector id : products, productsUpdate, orders, ordersStatus', true)->command("seeds")->description('create seeds file')->opt('id:i', 'seed id : categories', true); $this->args = $cli->parse($argv); }
protected function help(Cli $cli = null) { static::write_ln('PHP Bump version: version bumper and other git helpers'); static::write_ln('(c) quazardous <*****@*****.**>'); static::write_ln('Displays GIT commands you need.'); static::write_ln(); if ($cli) { $cli->writeHelp(); return; } static::write_ln('USAGE: bump_version <command> [...]'); static::write_ln('<command> can be:'); static::write_ln(' bump: bump version'); static::write_ln(' merge_into <branch>: merge current branch into given branch'); static::write_ln(' merge_from <branch>: merge given branch into current branch'); static::write_ln(); }
/** * Get the multiple command cli example. * * @return Cli */ public function getCommandCli() { // Define a cli with commands. $cli = Cli::create()->command('push')->description('Push data to a remote server.')->opt('force:f', 'Force an overwrite.', false, 'boolean')->opt('set-upstream:u', 'Add a reference to the upstream repo.', false, 'boolean')->command('pull')->description('Pull data from a remote server.')->opt('commit', 'Perform the merge and commit the result.', false, 'boolean')->command('*')->opt('verbose:v', 'Output verbose information.', false, 'boolean')->arg('repo', 'The repository to sync with.', true); return $cli; }
/** * Get a sample {@link Cli} object with no commands for testing. * * @return Cli Returns the sample {@link Cli} instance. */ protected function getBasicCli() { $cli = new Cli(); $cli->opt('hello:h', 'Hello world.', true, 'string')->opt('enabled:e', 'Enabled or not.', false, 'boolean')->opt('disabled:d', 'Disabled or not', false, 'bool')->opt('count:c', 'The count of things.', false, 'integer'); return $cli; }
/** * Test that the backwards compatibility of the format property works. */ public function testFormatCompat() { $cli = new Cli(); $format = $cli->format; $this->assertErrorNumber(E_USER_DEPRECATED); $this->assertSame($cli->getFormatOutput(), $format); $this->clearErrors(); $format2 = !$format; $cli->format = $format2; $this->assertErrorNumber(E_USER_DEPRECATED); $this->assertSame($format2, $cli->getFormatOutput()); }
<?php use Garden\Cli\Cli; error_reporting(E_ALL); //E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR); ini_set('display_errors', 'on'); ini_set('track_errors', 1); date_default_timezone_set('America/Montreal'); $paths = [__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php']; foreach ($paths as $path) { if (file_exists($path)) { require_once $path; break; } } $cli = new Cli(); $cli->opt('token', 'The github access token. Uses the GITHUB_API_TOKEN if not specified.')->opt('quiet:q', "Don't output verbose information.", false, 'boolean')->command('labels')->description('Copy the labels from one github repo to another.')->opt('from:f', 'The github repo to copy the labels from.', true)->opt('to:t', 'The github repo to copy the labels to.', true)->opt('delete:d', 'Pass one of force or prune to force delete or prune unused labels.', false)->command('milestones')->description('Copy milestones from one github repo to another.')->opt('from:f', 'The github repo to copy the labels from.', true)->opt('to:t', 'The github repo to copy the labels to.', true)->opt('status:s', 'The milestone status. One of open, closed, all. Defaults to open.')->opt('autoclose', 'Whether or not to close milestones that are overdue and don\'t have any items.', false, 'boolean')->command('overdue')->description('Label issues from an past due milestones as overdue.')->opt('repo:r', 'The github repo to inspect.', true); $args = $cli->parse($argv); try { $sync = new \Vanilla\Github\GithubSync($args->getOpt('token', getenv('GITHUB_API_TOKEN'))); $sync->setFromRepo($args->getOpt('from'))->setToRepo($args->getOpt('to'))->setMessageLevel($args->getOpt('quiet') ? 1 : 3); switch ($args->getCommand()) { case 'labels': $sync->syncLabels($args->getOpt('delete')); break; case 'milestones': $sync->syncMilestones($args->getOpt('status', 'open'), $args->getOpt('autoclose', false)); break; case 'overdue': $sync->setFromRepo($args->getOpt('repo')); $sync->labelOverdue();
/** * Test some basic color formatting. */ public function testColors() { $log = $this->createTestLogger(); $log->setFormatOutput(true)->setDateFormat(''); $log->success('y')->error('n'); $this->expectOutputString(Cli::greenText('y') . "\n" . Cli::redText('n') . "\n"); }
error_reporting(E_ALL); //E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR); ini_set('display_errors', 'on'); ini_set('track_errors', 1); date_default_timezone_set('America/Montreal'); $paths = [__DIR__ . '/../vendor/autoload.php', __DIR__ . '/../../../autoload.php']; foreach ($paths as $path) { if (file_exists($path)) { require_once $path; break; } } use Garden\Cli\Cli; use Garden\Cli\Schema; use Mustacher\Mustacher; $cli = new Cli(); $cli->description('Run mustache templates against a JSON file.')->opt('template:t', 'The path to the template file.', true)->opt('input:i', 'The path to the input JSON data file.')->opt('output:o', 'The path where the output will be written.')->opt('format:f', 'The format of the template file. Either mustache or message.')->opt('data:d', 'A JSON formatted data object. This will be merged on top of the input file if both are specified.'); $args = $cli->parse($argv); try { $data = Mustacher::mergeData($args->getOpt('input'), $args->getOpt('data')); $str = Mustacher::generateFile($args->getOpt('template'), $data, $args->getOpt('format', Mustacher::FORMAT_MUSTACHE)); } catch (Exception $ex) { echo $cli->red($ex->getMessage() . "\n"); die; } if ($args->getOpt('output')) { $path = $args->getOpt('output'); if (!file_exists(dirname($path))) { mkdir($path, 0777, true); } echo "Writing output file: {$path}\n";
protected static function registerDatabaseMySqlOpts(Cli $cli) { return $cli->opt('connection-collation', 'MySQL only: The collation to use, defaults to DB_COLLATION and "utf8_unicode_ci"')->opt('connection-strict', 'MySQL only: Force strict mode, detaults to DB_STRICT and false', false, 'boolean'); }
<?php require_once 'config.php'; require_once 'vendor/autoload.php'; use TimelineAPI\Pin; use TimelineAPI\PinLayout; use TimelineAPI\PinLayoutType; use TimelineAPI\PinIcon; use TimelineAPI\PinReminder; use TimelineAPI\Timeline; use Garden\Cli\Cli; define('PUSH', 'push'); define('DISPLAY', 'display'); $cli = Cli::create()->command('push')->description('Pushes pins to timeline API')->opt("testing:t", "Push pins using the sandbox key", false, 'boolean')->command('display')->description('Displays the JSON for the pins instead of pushing them to the API')->command('*')->opt('days-out:d', 'The number of days out to pull data from the GHTV API. Default is 3.', false, 'integer')->opt('num-items:i', 'The maximum number of items to pull from the GHTV API. Default is no limit.', false, 'integer'); $args = $cli->parse($argv); $command = $args->getCommand(); $daysout = $args->getOpt('days-out', 3); $numitems = $args->getOpt('num-items', PHP_INT_MAX); if ($command == PUSH && true === $args->getOpt('testing', false)) { $key = TEST_KEY; } else { $key = PROD_KEY; } $category_list = ["pop", "rock", "metal", "indie", "classics", "riffs", "jams", "hits", "smashes", "picks", "knockouts", "anthems", "headliners", "blockbusters"]; $d = json_decode(file_get_contents("https://www.guitarhero.com/api/papi-client/ghl/v1/channelSchedules/en/all/")); $data = $d->data; $programs = []; foreach ($data as $channel => $channel_details) { foreach ($channel_details->programmes as $program) { $title = $program->title; $program->channel = $channel_details->title;
public static function registerMigrationOpts(Cli $cli) { return $cli->opt('migration-path', 'The migration path to use, defaults to DB_MIGRATION_PATH and "database/migrations"')->opt('migration-table', 'The migration table to use, defaults to DB_MIGRATION_TABLE and "migrations"'); }