runHeapCli function
CLI adapter for fdb heap.
Output contract:
SNAPSHOT_SAVED=path (success)
Wrote N MB. Open in DevTools: Memory tab -> Import snapshot
Error cases:
ERROR: --output path is required (missing output)
ERROR: No Flutter isolate found in running app (no isolate)
ERROR: message (generic error)
Implementation
Future<int> runHeapCli(List<String> args) async {
if (args.isNotEmpty && (args[0] == '--help' || args[0] == '-h')) {
stdout.writeln(_heapUsage);
return 0;
}
if (args.isEmpty) {
stderr.writeln('ERROR: Missing subcommand for fdb heap. Run `fdb heap --help` for usage.');
return 1;
}
switch (args[0]) {
case 'dump':
return _runHeapDump(args.sublist(1));
default:
stderr.writeln('ERROR: Unknown subcommand for fdb heap: ${args[0]}');
stderr.writeln('Run `fdb heap --help` for usage.');
return 1;
}
}