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 {
  config = ConfigService(projectDir);

  final reset = argResults!['reset'] as bool;
  final clientsOption = argResults!['clients'] as String?;
  final notifyOnly = argResults!['notify'] as bool;

  try {
    if (reset) {
      await _resetConfiguration();
      return;
    }

    if (clientsOption != null) {
      await _handleClientsSetup(clientsOption);
      return;
    }

    if (notifyOnly) {
      await _handleNotificationSetup();
      return;
    }

    await _handleProjectSetup();
  } on BuildException catch (e, s) {
    Logger.error(e.message,
        cause: e.fix, stackTrace: e.originalStackTrace ?? s);
    rethrow;
  } catch (e, s) {
    Logger.error('An unexpected error occurred during setup.',
        cause: e, stackTrace: s);
    rethrow;
  }
}