parseRefArg function
Parses an fdb describe ref (@N, N >= 1) into N.
Writes ERROR: Invalid ref: <arg>. Expected @N where N >= 1 to stderr and
returns null when arg is malformed.
Implementation
int? parseRefArg(String arg) {
final ref = arg.startsWith('@') ? int.tryParse(arg.substring(1)) : null;
if (ref == null || ref < 1) {
stderr.writeln('ERROR: Invalid ref: $arg. Expected @N where N >= 1');
return null;
}
return ref;
}