run method

  1. @override
Future<void> run()
override

Executes the configure command.

It parses the command-line arguments, retrieves the client ID, and then calls the configureApp function to apply the configuration. If no client ID is provided, it attempts to use the last configured client ID, prompting the user for confirmation.

Implementation

@override
Future<void> run() async {
  final configureModel = ConfigureCommandModel.fromArgs(argResults!);

  if (configureModel.clientId == null) {
    final lastClientId = await getLastClientId();
    if (lastClientId != null && !(configureModel.skipAll)) {
      final answer = prompt(Messages.useLastClientIdMessage(lastClientId));
      if (answer.toLowerCase() == 'y') {
        configureModel.clientId = lastClientId;
        await configureApp(configureModel);
        return;
      }
    }
    throw CustomException(Messages.clientIdRequired);
  }
  await configureApp(configureModel);
}