extractVariables function

List<VariableInfo> extractVariables(
  1. String txt
)

Implementation

List<VariableInfo> extractVariables(String txt) {
  // extract the variable information from the latest glimpse(ds)
  String cmd = '> glimpse(ds)';
  String vars = rExtract(txt, cmd);

  final regex = RegExp(r'\$\s+(\w+)\s+<([^>]+)>\s+(.+)', multiLine: true);
  final matches = regex.allMatches(vars);

  return matches.map((match) {
    final name = match.group(1)!;
    final type = match.group(2)!;
    final details = match.group(3)!;

    return VariableInfo(name: name, type: type, details: details);
  }).toList();
}