run method
Executes the command using the provided command-line args.
Implementation
@override
Future<void> run(List<String> args) async {
if (args.isEmpty) {
LoggerService.error('Usage: $usage');
return;
}
final moduleName = args.first.trim();
final config = await ConfigService.load();
final template = await TemplateService.load(
config.defaultTemplate,
);
if (!template.modules.containsKey(moduleName)) {
LoggerService.error(
'Unknown module "$moduleName".',
);
LoggerService.blank();
LoggerService.info('Available modules:');
LoggerService.blank();
for (final entry in template.modules.entries) {
LoggerService.info(
' • ${entry.key.padRight(12)}'
'${entry.value.description}',
);
}
return;
}
LoggerService.section(
'Installing $moduleName',
);
final result = await const ModuleInstallationService().install(
config: config,
template: template,
moduleName: moduleName,
);
if (!result.installed) {
LoggerService.blank();
LoggerService.info(
'$moduleName installation cancelled.',
);
LoggerService.blank();
return;
}
LoggerService.blank();
LoggerService.success(
'$moduleName installed successfully.',
);
LoggerService.blank();
}