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 stt = context.yaml.getAsMap("app").getAsMap("speech_to_text");
  final permission = stt.getAsMap("permission");
  if (permission.isEmpty) {
    error(
      "The item [app]->[speech_to_text]->[permission] is missing. Please include the language code and the message when authorization is granted here.",
    );
    return;
  }
  await addFlutterImport(
    [
      "masamune_speech_to_text",
    ],
  );
  label("Addition of permission messages.");
  await XCodePermissionType.microphoneUsage.setMessageToXCode(
    permission
        .map((key, value) => MapEntry(key, value.toString()))
        .where((key, value) => value.isNotEmpty),
  );
  await XCodePermissionType.speechRecognitionUsage.setMessageToXCode(
    permission
        .map((key, value) => MapEntry(key, value.toString()))
        .where((key, value) => value.isNotEmpty),
  );
  await PodfilePermissionType.microphoneUsage.enablePermissionToPodfile();
  await PodfilePermissionType.speechRecognitionUsage
      .enablePermissionToPodfile();
  label("Edit AndroidManifest.xml.");
  await AndroidManifestPermissionType.recordAudio.enablePermission();
  await AndroidManifestPermissionType.bluetooth.enablePermission();
  await AndroidManifestPermissionType.bluetoothAdmin.enablePermission();
  await AndroidManifestPermissionType.bluetoothConnect.enablePermission();
  await AndroidManifestQueryType.speechToText.enableQuery();
}