code: public static int validate(String... argv) throws InterruptedException {
      if (argv.length < 1) {
        printHelp("Target not specified.");
        return -2;
      }
      String command = argv[0];
      String name = null;
      String[] args;
      int argsLength = 0;
      // Find all non-option command line arguments.
      while (argsLength < argv.length && !argv[argsLength].startsWith("-")) {
        argsLength++;
      }
      if (argsLength > 1) {
        name = argv[1];
        args = Arrays.copyOfRange(argv, 2, argv.length);
      } else {
        args = Arrays.copyOfRange(argv, 1, argv.length);
      }
  
      CommandLine cmd;
      try {
        cmd = parseArgsAndOptions(OPTIONS, args);
      } catch (InvalidArgumentException e) {
        System.err.format("Invalid argument: %s.%n", e.getMessage());
        return -1;
      }
      if (command != null && command.equals("list")) {
        printTasks();
        return 0;
      }
      return runTasks(command, name, cmd);
    }
docs: Validates environment.
  
  @param argv list of arguments
  @return 0 on success, -1 on validation failures, -2 on invalid arguments