exec method
Run command.
The contents of katana.yaml
and the arguments of the command are passed to context
.
コマンドを実行します。
context
にkatana.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", ""));
}
}