run method

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

Executes the build command.

It parses the command-line arguments, retrieves the client ID, and then calls the buildApps function to compile the application. 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 BuildCommandModel buildModel = BuildCommandModel.fromArgs(
    argResults!,
  );

  if (buildModel.clientId == null) {
    final lastClientId = await getLastClientId();
    if (lastClientId != null && !(buildModel.skipAll)) {
      final answer = prompt(Messages.useLastClientIdMessage(lastClientId));
      if (answer.toLowerCase() == 'y') {
        buildModel.clientId = lastClientId;
        await buildApps(buildModel);
        return;
      }
    }
    throw CustomException(Messages.clientIdRequiredForBuilding);
  } else {
    await buildApps(buildModel);
    // throw CustomException(Messages.clientIdRequiredForBuilding);
  }
}