code: public void registerClass(Class<?> clazz) {
          registeredClasses.add(clazz);
          for (Field field : clazz.getFields()) {
              if (field.isAnnotationPresent(Opt.class)) {
                  int mod = field.getModifiers();
                  if (!Modifier.isPublic(mod)) { throw new IllegalStateException("@"+Opt.class.getName()+" on non-public field: " + field); }
                  if (Modifier.isFinal(mod)) { throw new IllegalStateException("@"+Opt.class.getName()+" on final field: " + field); }
                  if (Modifier.isAbstract(mod)) { throw new IllegalStateException("@"+Opt.class.getName()+" on abstract field: " + field); }
  
                  // Add an Apache Commons CLI Option for this field.
                  Opt opt = field.getAnnotation(Opt.class);
  
                  String name = getName(opt, field);
                  if (!names.add(name)) {
                      throw new RuntimeException("Multiple options have the same name: --" + name);
                  }
  
                  String shortName = null;
                  if (createShortNames) {
                      shortName = getAndAddUniqueShortName(name);
                  }
                  
                  Option apacheOpt = new Option(shortName, name, opt.hasArg(), opt.description());                    
                  apacheOpt.setRequired(opt.required());
                  options.addOption(apacheOpt);
  
                  optionFieldMap.put(apacheOpt, field);
  
                  // Check that only boolean has hasArg() == false.
                  if (!field.getType().equals(Boolean.TYPE) && !opt.hasArg()) {
                      throw new RuntimeException("Only booleans can not have arguments.");
                  }
              }
          }
      }
docs: Registers all the @Opt annotations on a class with this ArgParser.