run method

  1. @override
void run()
override

Runs this command.

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

Implementation

@override
void run() async {
  if (argResults?.rest.firstOrNull == 'init') {
    init();
    return;
  }

  final pathPackageLocal2dart =
      join(current, 'core', 'packages', 'local2dart');
  if (!exists(pathPackageLocal2dart)) {
    await 'morpheme core local2dart'.run;
    await FlutterHelper.start('pub add sqflite path equatable',
        workingDirectory: join(pathPackageLocal2dart));
  }

  local2dart =
      YamlHelper.loadFileYaml(join(current, 'local2dart', 'local2dart.yaml'));

  generateCore(pathPackageLocal2dart);
  generateTableHelper(pathPackageLocal2dart);
  generateQueryTableHelper(pathPackageLocal2dart);
  generateViewHelper(pathPackageLocal2dart);
  generateService(pathPackageLocal2dart);
  generateDatabaseInstance(pathPackageLocal2dart);
  generateLocal2dart(pathPackageLocal2dart);

  await '${FlutterHelper.getCommandDart()} format .'
      .start(workingDirectory: pathPackageLocal2dart);

  StatusHelper.success('morpheme local2dart');
}