updateApplicationIdFromArguments function

Future<void> updateApplicationIdFromArguments(
  1. List<String> arguments
)

Implementation

Future<void> updateApplicationIdFromArguments(List<String> arguments) async {
  final parser = ArgParser(allowTrailingOptions: true);
  parser.addFlag(
    helpFlag,
    abbr: 'h',
    help: 'Usage help',
    negatable: false,
  );
  // Make default null to differentiate when it is explicitly set
  parser.addOption(
    fileOption,
    abbr: 'f',
    help: 'Config file (default: $DEFAULT_CONFIG_FILES)',
  );
  final argResults = parser.parse(arguments);

  if (argResults[helpFlag]) {
    stdout.writeln('Updates application id for iOS and Android');
    stdout.writeln(parser.usage);
    exit(0);
  }

  try {
    final config = await loadConfigFileFromArgResults(
      argResults,
      verbose: true,
    );

    await updateApplicationIdFromConfig(config);
  } catch (e) {
    if (e is InvalidFormatException) {
      stderr.writeln('Invalid configuration format.');
    } else {
      stderr.writeln(e);
    }
    exit(2);
  }
}