static Options read()

in Utils/status_files_checker.dart [77:126]


  static Options read(List<String> args) {
    Options options = new Options();
    if (args.length > 0) {
      for (var arg in args) {
        if (!_checkFormat(arg)) {
          throw OptionsException("Unknown argument: '$arg'");
        }
        List<String> pair = arg.substring(1).split("=");
        switch (pair[0]) {
          case "after":
            options.after = pair[1];
            break;
          case "before":
            options.before = pair[1];
            break;
          case "days":
            try {
              options.days = int.parse(pair[1]);
            } on FormatException catch (_) {
              throw new OptionsException(
                  "Unable to parse 'days' value: '${pair[0]}'");
            }
            DateTime da = DateTime.now().add(Duration(days: -options.days));
            options.after = _formatDate(da);
            break;
          case "sdk":
            options.sdk = pair[1];
            break;
          default:
            throw new OptionsException("Unknown argument: '${pair[0]}'");
        }
      }
      if (options.after == null) {
        DateTime da = DateTime.now().add(Duration(days: -options.days));
        options.after = _formatDate(da);
      }
      return options;
    } else {
      print('''
      This tool checks if recent commits contain tests mentioned in .status files. Usage:
      dart status_files_checker.dart <options>
      Options:
      -after=yyyy-MM-dd - by default current date minus ${options.days} days
      -before=yyyy-MM-dd - current date by default
      -days=N - check commits for N latest days (${options.days} by default)
      -sdk=path_to_sdk - path to Dart SDK (by default it's the current directory)
    ''');
      throw EmptyOptionsException();
    }
  }