new ClassParser().parse(authenticator, parser);
new ClassParser().parse(authenticator,p);
/** * Creates a new command line owner that * parses arguments/options and set them into * the given object. * * @param bean * instance of a class annotated by {@link Option} and {@link Argument}. * this object will receive values. If this is {@code null}, the processing will * be skipped, which is useful if you'd like to feed metadata from other sources. * * @param parserProperties various settings for this class * * @throws IllegalAnnotationError * if the option bean class is using args4j annotations incorrectly. */ public CmdLineParser(Object bean, ParserProperties parserProperties) { this.parserProperties = parserProperties; // A 'return' in the constructor just skips the rest of the implementation // and returns the new object directly. if (bean==null) return; // Parse the metadata and create the setters new ClassParser().parse(bean,this); if (parserProperties.getOptionSorter()!=null) { Collections.sort(options, parserProperties.getOptionSorter()); } }
/** * Creates a new command line owner that * parses arguments/options and set them into * the given object. * * @param bean * instance of a class annotated by {@link Option} and {@link Argument}. * this object will receive values. If this is {@code null}, the processing will * be skipped, which is useful if you'd like to feed metadata from other sources. * * @param parserProperties various settings for this class * * @throws IllegalAnnotationError * if the option bean class is using args4j annotations incorrectly. */ public CmdLineParser(Object bean, ParserProperties parserProperties) { this.parserProperties = parserProperties; // A 'return' in the constructor just skips the rest of the implementation // and returns the new object directly. if (bean==null) return; // Parse the metadata and create the setters new ClassParser().parse(bean,this); if (parserProperties.getOptionSorter()!=null) { Collections.sort(options, parserProperties.getOptionSorter()); } }
/** * Recursively visits object graph, finds all {@link HasOptions} components, * and adds them all to the parser. */ private void collectComponentsWithOptions(CmdLineParser p, Object o, Set<Object> collected) { for (Class c = o.getClass(); c!=null; c=c.getSuperclass()) { for (Field f : c.getDeclaredFields()) { if (f.isAnnotationPresent(Inject.class) && HasOptions.class.isAssignableFrom(f.getType())) { try { f.setAccessible(true); Object child = f.get(o); if (child!=null && collected.add(child)) { new ClassParser().parse(child,p); collectComponentsWithOptions(p,child,collected); } } catch (IllegalAccessException e) { throw new Error(e); } } } } }
/** * Creates a new command line owner that * parses arguments/options and set them into * the given object. * * @param bean * instance of a class annotated by {@link Option} and {@link Argument}. * this object will receive values. If this is {@code null}, the processing will * be skipped, which is useful if you'd like to feed metadata from other sources. * * @param parserProperties various settings for this class * * @throws IllegalAnnotationError * if the option bean class is using args4j annotations incorrectly. */ public CmdLineParser(Object bean, ParserProperties parserProperties) { this.parserProperties = parserProperties; // A 'return' in the constructor just skips the rest of the implementation // and returns the new object directly. if (bean==null) return; // Parse the metadata and create the setters new ClassParser().parse(bean,this); if (parserProperties.getOptionSorter()!=null) { Collections.sort(options, parserProperties.getOptionSorter()); } }
/** * Creates a new command line owner that * parses arguments/options and set them into * the given object. * * @param bean * instance of a class annotated by {@link Option} and {@link Argument}. * this object will receive values. If this is {@code null}, the processing will * be skipped, which is useful if you'd like to feed metadata from other sources. * * @param parserProperties various settings for this class * * @throws IllegalAnnotationError * if the option bean class is using args4j annotations incorrectly. */ public CmdLineParser(Object bean, ParserProperties parserProperties) { this.parserProperties = parserProperties; // A 'return' in the constructor just skips the rest of the implementation // and returns the new object directly. if (bean==null) return; // Parse the metadata and create the setters new ClassParser().parse(bean,this); if (parserProperties.getOptionSorter()!=null) { Collections.sort(options, parserProperties.getOptionSorter()); } }
public int run(String[] args) throws Exception { CmdLineParser p = new CmdLineParser(this); new ClassParser().parse(signer, p); try { p.parseArgument(args); if (argumentsFile == null) { run(); } else { List<String> invocations = IOUtils.readLines(new FileReader(argumentsFile)); for (String line : invocations) { if (!line.trim().startsWith("#") && !line.trim().isEmpty()) { System.err.println("Running with args: " + line); // TODO combine args array and this list String[] invocationArgs = line.split(" +"); resetArguments(); this.signer = new Signer(); p = new CmdLineParser(this); new ClassParser().parse(signer, p); p.parseArgument(invocationArgs); run(); } } } return 0; } catch (CmdLineException e) { System.err.println(e.getMessage()); p.printUsage(System.err); return 1; } }
new ClassParser().parse(authenticator, parser);
new ClassParser().parse(authenticator, parser);
new ClassParser().parse(authenticator,parser);
new ClassParser().parse(authenticator,parser);
new ClassParser().parse(authenticator,parser);
new ClassParser().parse(authenticator,p);
new ClassParser().parse(authenticator,p);
new ClassParser().parse(authenticator,p);
new ClassParser().parse(authenticator, p);
new ClassParser().parse(authenticator,p);