run method
Executes the command using the provided command-line args.
Implementation
@override
Future<void> run(List<String> args) async {
final configFile = File('fkit.yaml');
if (configFile.existsSync()) {
LoggerService.warning(
'Existing FKIT configuration detected.',
);
try {
final content = await configFile.readAsString();
final match = RegExp(
r'project_name:\s*(.*)',
).firstMatch(content);
final projectName = match?.group(1)?.trim();
if (projectName != null && projectName.isNotEmpty) {
LoggerService.info(
'Project: $projectName',
);
}
} catch (_) {}
LoggerService.blank();
final replace = PromptService.confirm(
'Do you want to replace it?',
);
if (!replace) {
LoggerService.blank();
LoggerService.warning(
'Initialization cancelled.',
);
LoggerService.blank();
return;
}
LoggerService.blank();
}
final config = await InitWizard().start();
await configFile.writeAsString(
YamlGenerator.generate(config),
);
LoggerService.blank();
LoggerService.success(
'fkit.yaml created successfully.',
);
LoggerService.blank();
}