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.

コマンドを実行します。

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

Implementation

@override
Future<void> exec(ExecContext context) async {
  final args = context.args;
  final selections = <String>[];
  for (var i = 0; i < args.length; i++) {
    if (args[i] == "--target") {
      if (++i >= args.length) {
        throw const FormatException("--target requires a name.");
      }
      selections.add(args[i]);
    } else if (args[i].startsWith("--target=")) {
      selections.add(args[i].substring(9));
    }
  }
  if (selections.length != 1) {
    throw const FormatException(
        "app.targets requires exactly one explicit --target.");
  }
  await NativeAppTarget.apply(
      context.yaml.getAsMap("app").getAsMap("targets"), selections.single);
}