exec static method

bool exec(
  1. List<String> args, {
  2. CliOptSubCmdMap? map,
})

Check the first argument is a sub-command and execute the parser mapped to that

Implementation

static bool exec(List<String> args, {CliOptSubCmdMap? map}) {
  final argCount = args.length;
  final subCmd = (argCount <= 0 ? '' : args[0]);

  if (!subCmd.isCliSubCmdValid()) {
    return false;
  }

  final parser = map?[subCmd];

  if (parser == null) {
    return false;
  }

  parser(args.sublist(1));
  return true;
}