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); }
/** * 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; }
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(); break;
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'); }
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"'); }