Args { public static ArgsInfo from(Object... sources) throws IOException { return from(ImmutableList.copyOf(sources)); } private  Args(); static ArgsInfo from(Object... sources); static ArgsInfo from(Predicate<Field> filter, Object... sources); static ArgsInfo from(Iterable<?> sources); static ArgsInfo from(Predicate<Field> filter, Iterable<?> sources);  }
@Test public void testMixed() throws IOException { App app = new App(); new ArgScanner().parse(Args.from(ArgFilters.selectClass(App.class), app), ImmutableList.of("-name=bob", "-db=fred", "1", "137")); assertEquals(new File("fred"), App.DB.get()); assertEquals("bob", app.name.get()); }
@Test public void testReentrance() throws IOException { class InnerApp { @Range(lower = 0.0, upper = 1.0) @CmdLine(name = "level", help = "help") private final Arg<Double> level = Arg.create(); } InnerApp app1 = new InnerApp(); InnerApp app2 = new InnerApp(); new ArgScanner().parse(Args.from(ArgFilters.selectClass(InnerApp.class), app1), ImmutableList.of("-level=0.5")); new ArgScanner().parse(Args.from(ArgFilters.selectClass(InnerApp.class), app2), ImmutableList.of("-level=0.00729")); assertEquals(0.5, app1.level.get(), 0.00001); assertEquals(0.00729, app2.level.get(), 0.00001); }