run method

void run(
  1. List<String> args
)

Implementation

void run(List<String> args) {
  String? componentName;

  if (args.isNotEmpty) {
    componentName = args[0];
  } else {
    stdout.write('Vui lòng nhập tên component: ');
    componentName = stdin.readLineSync();
    if (componentName == null || componentName.trim().isEmpty) {
      print('Tên component không được để trống.');
      exit(1);
    }
  }

  final rawName = componentName.trim();
  final className = 'DS$rawName';
  final snakeName = _toSnakeCaseWithPrefix(rawName);

  try {
    _createComponentWidget(className, snakeName);
    _createThemeComponent(className, snakeName);
    _updateDsThemeFile(snakeName);
    _updateDsAppThemeExtensions(className);
    _formatCode();
  } catch (e, st) {
    print('Lỗi khi tạo component: $e');
    print(st);
    exit(1);
  }
}