File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -5,9 +5,11 @@ import 'package:celest_cli/src/commands/auth/cli_auth.dart';
55import 'package:celest_cli/src/commands/celest_command.dart' ;
66import 'package:celest_cli/src/context.dart' ;
77import 'package:celest_cli/src/exceptions.dart' ;
8+ import 'package:celest_cli/src/repositories/cloud_repository.dart' ;
89import 'package:corks_cedar/corks_cedar.dart' ;
910
10- final class LoginCommand extends CelestCommand with Authenticate {
11+ final class LoginCommand extends CelestCommand
12+ with Authenticate , CloudRepository {
1113 LoginCommand () {
1214 argParser.addOption (
1315 'token' ,
@@ -47,6 +49,16 @@ final class LoginCommand extends CelestCommand with Authenticate {
4749 throw CliException ('Failed to authenticate with token.' );
4850 }
4951
52+ Future <void > _ensurePrimaryOrg () async {
53+ final primaryOrg = await primaryOrganization;
54+ if (primaryOrg != null ) {
55+ logger.finest ('Primary organization: ${primaryOrg .displayName }' );
56+ return ;
57+ }
58+ cliLogger.success ('Welcome to Celest Cloud!' );
59+ await createPrimaryOrg ();
60+ }
61+
5062 @override
5163 Future <int > run () async {
5264 await super .run ();
@@ -68,6 +80,7 @@ final class LoginCommand extends CelestCommand with Authenticate {
6880 if (res != 0 ) {
6981 return res;
7082 }
83+ await _ensurePrimaryOrg ();
7184 cliLogger.success ('You have been logged in!' );
7285 }
7386
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ dependencies:
2222 celest_auth : ^1.0.0
2323 celest_cloud : ^0.1.5-0
2424 celest_cloud_auth : ^0.3.0-0
25+ celest_cloud_core : ^0.1.0
2526 celest_core : ^1.0.0
2627 chunked_stream : ^1.4.2
2728 cli_script : ^1.0.0
You can’t perform that action at this time.
0 commit comments