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 synchronizer = DebuggableProjectSynchronizer(Directory.current);
  late final DebuggableProjectPlan plan;
  try {
    plan = await synchronizer.createPlan();
  } on Object catch (exception) {
    error(exception.toString());
    return;
  }

  final bin = context.yaml.getAsMap("bin");
  final flutter = bin.get("flutter", "flutter");
  label("Add the masamune_ai_debugger package if it is missing.");
  await addFlutterImport(
    const ["masamune_ai_debugger"],
    flutterCommand: flutter,
  );
  if (isError) {
    return;
  }

  label("Configure Masamune AI Debugger.");
  await synchronizer.apply(plan);
  // ignore: avoid_print
  print("Masamune AI Debugger configuration is complete.");
}