From b0aa1097b29b7fd9fa35fd26f65ac952c8968ccb Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Wed, 24 Dec 2025 11:23:44 +0100 Subject: [PATCH] Add 'whoami' command --- src/Application.php | 1 + src/Commands/Whoami.php | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 src/Commands/Whoami.php diff --git a/src/Application.php b/src/Application.php index 6a49b6b..14459e7 100644 --- a/src/Application.php +++ b/src/Application.php @@ -22,6 +22,7 @@ public function __construct() $this->turnWarningsIntoExceptions(); $this->safeAddCommand(new Commands\Login); + $this->safeAddCommand(new Commands\Whoami); $this->safeAddCommand(new Commands\Deploy); $this->safeAddCommand(new Commands\Info); $this->safeAddCommand(new Commands\Remove); diff --git a/src/Commands/Whoami.php b/src/Commands/Whoami.php new file mode 100644 index 0000000..0259b45 --- /dev/null +++ b/src/Commands/Whoami.php @@ -0,0 +1,36 @@ +setName('whoami') + ->setDescription('Show the currently logged in user'); + } + + protected function execute(InputInterface $input, OutputInterface $output): int + { + IO::init($input, $output); + + try { + $brefCloud = new BrefCloudClient(); + $user = $brefCloud->getUserInfo(); + } catch (Exception) { + IO::writeln('Not logged in. Run "bref login" to authenticate.'); + return 1; + } + + IO::writeln("Logged in to Bref Cloud as {$user['name']} ({$user['email']})"); + return 0; + } +}