findSelectedParser method

ArgParser findSelectedParser()

Returns the farthest parser the user has selected (i.e. given mycommand subcommand1 subcommand2, returns the parser for subcommand2). This interface is not guaranteed to be stable!

Implementation

ArgParser findSelectedParser() {
  var currentParser = this;

  while (true) {
    var commandSet = currentParser.args.commandSet;
    if (commandSet == null || commandSet.valueHolder.isValueEmpty) {
      break;
    }

    var commandId = commandSet.printer(commandSet.valueHolder.value);
    currentParser = currentParser.commandParsers[commandId]!;
  }

  return currentParser;
}