run method

  1. @override
FutureOr run()
override

Runs this command.

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

Implementation

@override
FutureOr run() async {
  if (!CliHelper.existConfig(projectDir) || force) {
    _saveConfig();
  } else {
    final answer = prompts.get(
      'Config file already exists. You want override them?(y/n)',
      defaultsTo: 'n',
      validate: (value) {
        final safeValue = value.trim().toLowerCase();
        return ['y', 'n', 'yes', 'no'].contains(safeValue);
      },
    );

    if (answer.substring(0, 1) == 'y') {
      _saveConfig();
    }
  }
}