route static method
Route to the appropriate entrypoint and run.
Implementation
static Future<void> route(List<String> args, Map<String, String> env) async {
final mode = detect(args, env);
switch (mode) {
case EntryMode.interactive:
// Launch the Flutter/TUI interactive mode.
break;
case EntryMode.cli:
final config = const CliEntrypoint().parse(args);
final errors = const CliEntrypoint().validateConfig(config);
if (errors.isNotEmpty) {
for (final err in errors) {
stderr.writeln('Error: $err');
}
exit(1);
}
// Execute CLI mode with the parsed config.
break;
case EntryMode.sdk:
// SDK mode is invoked programmatically, not from the CLI.
break;
case EntryMode.mcpServer:
// Start MCP server.
break;
case EntryMode.headless:
// Run in headless mode.
break;
case EntryMode.embedded:
// Embedded mode is invoked by the host app.
break;
case EntryMode.remote:
// Start in listen/remote mode.
break;
case EntryMode.piped:
await const PipedEntrypoint().run(const PipedConfig());
}
}