runOmnyServerCli function
Runs the CLI with args, handling usage and CLI errors with exit codes.
Implementation
Future<void> runOmnyServerCli(List<String> args) async {
final runner = buildRunner();
try {
final top = runner.parse(args);
if (top['version'] as bool) {
stdout.writeln('omnyserver $omnyServerVersion');
return;
}
await runner.run(args);
} on UsageException catch (e) {
stderr.writeln(e);
exitCode = 64;
} on CliError catch (e) {
stderr.writeln('error: ${e.message}');
exitCode = 1;
} on HubApiException catch (e) {
stderr.writeln('error: ${e.message}');
exitCode = 1;
} on OmnyServerException catch (e) {
// A classified runtime failure that reached the top — e.g. a node whose
// credential the Hub rejected outright (terminal auth). Print the message,
// not a stack trace.
stderr.writeln('error: ${e.message}');
exitCode = 1;
}
}