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 {
  final results = argResults;
  if (results == null) throw ArgumentError('No arguments provided');

  final isDevelopmentCertificate =
      (results[argDevelopment] as bool?) ?? false;

  final (p12PrivateKeyBase64, certBase64) = await IosSigningPrepare()
      .createCertificate(
          isDevelopment: isDevelopmentCertificate, force: true);

  print('Example command to set the environment variables:\n');

  final certType = isDevelopmentCertificate ? 'DEVELOPMENT' : 'DISTRIBUTION';
  final exampleCommand = '''
export \\
  IOS_${certType}_PRIVATE_KEY=$p12PrivateKeyBase64 \\
  IOS_${certType}_CERT=$certBase64\n
  ''';

  print(exampleCommand);
}