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 {
  final argMorphemeYaml = argResults.getOptionMorphemeYaml();

  YamlHelper.validateMorphemeYaml(argMorphemeYaml);

  final yaml = YamlHelper.loadFileYaml(argMorphemeYaml);
  final Map repository = yaml['repository'] ?? {};

  if (repository.isNotEmpty) {
    repository.forEach(
      (key, value) {
        if (!exists(key)) {
          'git clone $value $key'.run;
        } else {
          'git fetch'.start(
            workingDirectory: key,
          );
          'git pull'.start(
            workingDirectory: key,
          );
        }
      },
    );

    StatusHelper.success('morpheme repository');
  } else {
    StatusHelper.warning(
      'You do not have any repository in $argMorphemeYaml',
    );
  }
}