File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed
Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ public function __construct()
2222 $ this ->turnWarningsIntoExceptions ();
2323
2424 $ this ->safeAddCommand (new Commands \Login );
25+ $ this ->safeAddCommand (new Commands \Whoami );
2526 $ this ->safeAddCommand (new Commands \Deploy );
2627 $ this ->safeAddCommand (new Commands \Info );
2728 $ this ->safeAddCommand (new Commands \Remove );
Original file line number Diff line number Diff line change 1+ <?php declare (strict_types=1 );
2+
3+ namespace Bref \Cli \Commands ;
4+
5+ use Bref \Cli \BrefCloudClient ;
6+ use Bref \Cli \Cli \IO ;
7+ use Exception ;
8+ use Symfony \Component \Console \Command \Command ;
9+ use Symfony \Component \Console \Input \InputInterface ;
10+ use Symfony \Component \Console \Output \OutputInterface ;
11+
12+ class Whoami extends Command
13+ {
14+ protected function configure (): void
15+ {
16+ $ this
17+ ->setName ('whoami ' )
18+ ->setDescription ('Show the currently logged in user ' );
19+ }
20+
21+ protected function execute (InputInterface $ input , OutputInterface $ output ): int
22+ {
23+ IO ::init ($ input , $ output );
24+
25+ try {
26+ $ brefCloud = new BrefCloudClient ();
27+ $ user = $ brefCloud ->getUserInfo ();
28+ } catch (Exception ) {
29+ IO ::writeln ('Not logged in. Run "bref login" to authenticate. ' );
30+ return 1 ;
31+ }
32+
33+ IO ::writeln ("Logged in to Bref Cloud as {$ user ['name ' ]} ( {$ user ['email ' ]}) " );
34+ return 0 ;
35+ }
36+ }
You can’t perform that action at this time.
0 commit comments