Skip to content

Commit

Permalink
Merge pull request #53 from t-geindre/feature/add-missing-stage-option
Browse files Browse the repository at this point in the history
Add missing stage option
  • Loading branch information
mnapoli authored Aug 3, 2018
2 parents f55b484 + d30a1c3 commit ecb1535
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions bref
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,9 @@ $app->command(
/**
* Run a CLI command in the remote environment.
*/
$app->command('cli [arguments]*', function (array $arguments, SymfonyStyle $io) {
$serverlessInfo = (new Process('serverless info'))->mustRun()->getOutput();
$app->command('cli [--stage=] [arguments]*', function (?string $stage, array $arguments, SymfonyStyle $io) {
$stageOption = $stage ? ' --stage ' . escapeshellarg($stage) : '';
$serverlessInfo = (new Process('serverless info'.$stageOption))->mustRun()->getOutput();
foreach (explode(PHP_EOL, $serverlessInfo) as $line) {
if (strpos($line, 'region: ') === 0) {
$region = substr($line, strlen('region: '));
Expand Down Expand Up @@ -125,19 +126,23 @@ $app->command('cli [arguments]*', function (array $arguments, SymfonyStyle $io)
return (int) ($payload['exitCode'] ?? 1);
});

$app->command('info', function (SymfonyStyle $io) {
$io->write((new Process('serverless info'))->mustRun()->getOutput());
$app->command('info [--stage=]', function (?string $stage, SymfonyStyle $io) {
$stageOption = $stage ? ' --stage ' . escapeshellarg($stage) : '';
$io->write((new Process('serverless info'.$stageOption))->mustRun()->getOutput());
});

$app->command('remove', function (SymfonyStyle $io) {
$app->command('remove [--stage=]', function (?string $stage, SymfonyStyle $io) {
$stageOption = $stage ? ' --stage ' . escapeshellarg($stage) : '';
$io->write((new Process('serverless remove'))->mustRun()->getOutput());
});

$app->command('logs', function (SymfonyStyle $io) {
$app->command('logs [--stage=]', function (?string $stage, SymfonyStyle $io) {
$stageOption = $stage ? ' --stage ' . escapeshellarg($stage) : '';
$io->write((new Process('serverless logs -f main'))->mustRun()->getOutput());
});

$app->command('invoke', function (SymfonyStyle $io) {
$app->command('invoke [--stage=]', function (?string $stage, SymfonyStyle $io) {
$stageOption = $stage ? ' --stage ' . escapeshellarg($stage) : '';
$io->write((new Process('serverless invoke -f main'))->mustRun()->getOutput());
});

Expand Down

0 comments on commit ecb1535

Please sign in to comment.