launchInTerminal function

Future<bool> launchInTerminal(
  1. String neomagePath,
  2. DeepLinkAction action, {
  3. String? storedPreference,
})

Launch Neomage in the detected terminal emulator.

Implementation

Future<bool> launchInTerminal(
  String neomagePath,
  DeepLinkAction action, {
  String? storedPreference,
}) async {
  final terminal = await detectTerminal(storedPreference: storedPreference);
  if (terminal == null) {
    _logDebug('No terminal emulator detected');
    return false;
  }

  _logDebug('Launching in terminal: ${terminal.name} (${terminal.command})');
  final neomageArgs = ['--deep-link-origin'];
  if (action.repo != null) {
    neomageArgs.addAll(['--deep-link-repo', action.repo!]);
  }
  if (action.query != null) {
    neomageArgs.addAll(['--prefill', action.query!]);
  }

  if (Platform.isMacOS) {
    return _launchMacosTerminal(
      terminal,
      neomagePath,
      neomageArgs,
      action.cwd,
    );
  } else if (Platform.isLinux) {
    return _launchLinuxTerminal(
      terminal,
      neomagePath,
      neomageArgs,
      action.cwd,
    );
  } else if (Platform.isWindows) {
    return _launchWindowsTerminal(
      terminal,
      neomagePath,
      neomageArgs,
      action.cwd,
    );
  }
  return false;
}