run method

  1. @override
Future<PluginRunResult> run(
  1. PluginCommandConfig command,
  2. Device? device
)
override

Launches command for device, resolving argument templates.

Implementation

@override
Future<PluginRunResult> run(
  PluginCommandConfig command,
  Device? device,
) async {
  final args = command.resolveArgs(device);
  try {
    switch (command.mode) {
      case PluginRunMode.detached:
        await Process.start(
          command.command,
          args,
          mode: ProcessStartMode.detached,
        );
      case PluginRunMode.inherit:
        await Process.start(
          command.command,
          args,
          mode: ProcessStartMode.inheritStdio,
        );
    }
    return PluginRunResult(
      success: true,
      message: '${command.label} started',
    );
  } catch (e) {
    return PluginRunResult(
      success: false,
      message: 'Failed to run ${command.label}: $e',
    );
  }
}