Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public function __construct()

$this->safeAddCommand(new Commands\Login);
$this->safeAddCommand(new Commands\Whoami);
$this->safeAddCommand(new Commands\Teams);
$this->safeAddCommand(new Commands\Deploy);
$this->safeAddCommand(new Commands\Info);
$this->safeAddCommand(new Commands\Remove);
Expand Down
4 changes: 2 additions & 2 deletions src/BrefCloudClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static function getUrl(): string
}

/**
* @return array{id: int, name: string}
* @return array{id: int, name: string, email: string}
* @throws HttpExceptionInterface
* @throws ExceptionInterface
*/
Expand Down Expand Up @@ -238,7 +238,7 @@ public function listAwsAccounts(): array
}

/**
* @return list<array{id: int, name: string}>
* @return list<array{id: int, name: string, slug: string}>
*
* @throws HttpExceptionInterface
* @throws ExceptionInterface
Expand Down
36 changes: 36 additions & 0 deletions src/Commands/Teams.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php declare(strict_types=1);

namespace Bref\Cli\Commands;

use Bref\Cli\BrefCloudClient;
use Bref\Cli\Cli\IO;
use Exception;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class Teams extends Command
{
protected function configure(): void
{
$this
->setName('teams')
->setDescription('List the Bref Cloud teams you have access to');
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$teams = (new BrefCloudClient)->listTeams();

if (empty($teams)) {
IO::writeln('You do not have access to any teams.');
return 0;
}

foreach ($teams as $team) {
IO::writeln(sprintf("%s (%s)", $team['slug'], $team['name']));
}

return 0;
}
}
5 changes: 1 addition & 4 deletions src/Commands/Whoami.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{
IO::init($input, $output);

try {
$brefCloud = new BrefCloudClient();
$user = $brefCloud->getUserInfo();
$user = (new BrefCloudClient)->getUserInfo();
} catch (Exception) {
IO::writeln('Not logged in. Run "bref login" to authenticate.');
return 1;
Expand Down