exec method

  1. @override
Future<void> exec(
  1. ExecContext context
)
override

Run command.

The contents of katana.yaml and the arguments of the command are passed to context.

コマンドを実行します。

contextkatana.yamlの内容やコマンドの引数が渡されます。

Implementation

@override
Future<void> exec(ExecContext context) async {
  final app = context.yaml.getAsMap("app");
  if (app.isEmpty) {
    error("The item [app] is missing. Please add an item.");
    return;
  }
  final privacyManifest = app.getAsMap("privacy_manifests");
  if (privacyManifest.isEmpty) {
    error(
        "The item [app]->[privacy_manifests] is missing. Please add an item.");
    return;
  }
  final manifests = privacyManifest.getAsList<Map>("manifests").map((item) {
    return item.map((key, value) => MapEntry(key.toString(), value));
  });
  if (manifests.isEmpty) {
    error(
        "The item [app]->[privacy_manifests]->[manifests] is missing. Please add an item.");
    return;
  }
  label("Edit PrivacyInfo.xcprivacy.");
  for (final manifest in manifests) {
    final value = XCodePrivacyManifests.values.firstWhereOrNull(
      (item) => item.id == manifest.get("type", ""),
    );
    if (value == null) {
      continue;
    }
    await value.setPrivacyManifestToXCode(manifest.get("reason", ""));
  }
}