-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathstart_command.dart
More file actions
62 lines (51 loc) · 1.66 KB
/
start_command.dart
File metadata and controls
62 lines (51 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import 'package:celest_cli/src/commands/celest_command.dart';
import 'package:celest_cli/src/context.dart';
import 'package:celest_cli/src/frontend/celest_frontend.dart';
import 'package:celest_cli/src/frontend/child_process.dart';
import 'package:celest_cli/src/init/project_init.dart';
import 'package:celest_cli/src/init/project_migrate.dart';
import 'package:mason_logger/mason_logger.dart';
final class StartCommand extends CelestCommand
with Configure, Migrate, ProjectCreator {
StartCommand() {
argParser.addOption(
'template',
abbr: 't',
help: 'The project template to use.',
allowed: ['hello', 'data'],
allowedHelp: {
'hello': 'A simple greeting API.',
'data': 'A project with a database and cloud functions.',
},
defaultsTo: 'hello',
hide: true,
);
}
@override
String get description => 'Starts a local Celest environment.';
@override
String get name => 'start';
@override
String get category => 'Project';
@override
Progress? currentProgress;
@override
late final String template = argResults!.option('template')!;
@override
Future<int> run() async {
await super.run();
await checkForLatestVersion();
final needsMigration = await configure();
currentProgress ??= cliLogger.progress('Starting local environment');
ChildProcess? childProcess;
if (argResults!.rest case final command when command.isNotEmpty) {
childProcess = ChildProcess(command);
}
// Start the Celest Frontend Loop
return CelestFrontend().run(
migrateProject: needsMigration,
currentProgress: currentProgress,
childProcess: childProcess,
);
}
}