code: protected void parseArguments(String[] arguments) {
          LinkedList<String> args = new LinkedList<String>(Arrays.asList(arguments));
  
          boolean valid = true;
          while (!args.isEmpty()) {
              String arg = args.removeFirst();
  
              boolean handled = false;
              for (Option option : options) {
                  if (option.processOption(arg, args)) {
                      handled = true;
                      break;
                  }
              }
              if (!handled) {
                  System.out.println("Unknown option: " + arg);
                  System.out.println();
                  valid = false;
                  break;
              }
          }
          if (!valid) {
              showOptions();
              completed();
          }
      }
docs: Parses the command line arguments.