runLslCli function
Run the lsl command line tool with args; returns the exit code.
stop ends long-running commands (default: Ctrl-C).
Implementation
Future<int> runLslCli(
List<String> args, {
Future<void>? stop,
StringSink? out,
}) async {
final o = out ?? stdout;
final runner =
CommandRunner<int>(
'lsl',
'Lab Streaming Layer from the command line: list, record, share and '
'bridge streams.',
)
..argParser.addMultiOption(
'peer',
help:
'Address of a computer to look for streams on, where multicast '
'does not reach (repeat for more).',
);
for (final c in <Command<int>>[
_List(o),
_Info(o),
_Record(o, stop),
_Share(o, stop),
_Share(o, stop, relay: true),
_Bridge(o, stop),
_Publish(o, stop),
_Generate(o, stop),
_Replay(o, stop),
_Cyton(o, stop),
]) {
runner.addCommand(c);
}
try {
final parsed = runner.parse(args);
final peers = parsed['peer'] as List<String>;
if (peers.isNotEmpty) {
lsl.configure(LslNetworkOptions(knownPeers: peers));
}
return await runner.runCommand(parsed) ?? 0;
} on UsageException catch (e) {
o.writeln(e);
return 64;
} finally {
_discovery?.close();
_discovery = null;
}
}