run method

  1. @override
Future<void> run()
override

Runs this command.

The return value is wrapped in a Future if necessary and returned by CommandRunner.runCommand.

Implementation

@override
Future<void> run() async {
  if (argResults!.rest.isEmpty) {
    Logger.error('Please specify a component name');
    exit(1);
  }

  final componentName = argResults!.rest.first;
  final outputDir = argResults!['output-dir'] as String;

  try {
    await _createComponent(componentName, outputDir);
    Logger.success('Successfully created $componentName component');
  } catch (e) {
    Logger.error('Failed to create component: ${e.toString()}');
    exit(1);
  }
}