resolve method
The apps a command runs on, printing to output why when there are
none. Per-command -d and --all in options win over use.
Implementation
Future<({List<LiveApp> targets, int exitCode})> resolve(
LiveOptions options,
LivePrinter output,
) async {
if (options.uri != null) {
output.error(
'--uri only works when starting the shell: metro live --uri <address>',
);
return (targets: <LiveApp>[], exitCode: 64);
}
await _pruneClosed();
if (_apps.isEmpty) await _refreshQuietly();
LiveTargetSelection<LiveApp> selection = _pick(options);
if (!selection.isSuccess && _apps.isNotEmpty) {
await _refreshQuietly();
selection = _pick(options);
}
if (!selection.isSuccess) {
output.error(selection.error!);
for (final LiveApp app in selection.candidates) {
output.line(' ${_apps.indexOf(app) + 1} ${app.device}');
}
return (targets: <LiveApp>[], exitCode: selection.exitCode);
}
return (targets: selection.targets, exitCode: 0);
}