use of com.twitter.common.args.Args.ArgsInfo in project commons by twitter.
the class ArgScanner method parse.
/**
* Applies the provided argument values to any {@literal @CmdLine} or {@literal @Positional}
* {@code Arg} fields discovered on the classpath and accepted by the given {@code filter}.
*
* @param filter A predicate that selects or rejects scanned {@literal @CmdLine} fields for
* argument application.
* @param args Argument values to map, parse, validate, and apply.
* @return {@code true} if the given {@code args} were successfully applied to their corresponding
* {@link Arg} fields.
* @throws ArgScanException if there was a problem loading {@literal @CmdLine} argument
* definitions
* @throws IllegalArgumentException If the arguments provided are invalid based on the declared
* arguments found.
*/
public boolean parse(Predicate<Field> filter, Iterable<String> args) {
Preconditions.checkNotNull(filter);
ImmutableList<String> arguments = ImmutableList.copyOf(args);
Configuration configuration = load();
ArgsInfo argsInfo = Args.fromConfiguration(configuration, filter);
return parse(argsInfo, arguments);
}
Aggregations