public final class CommandLine extends Object
| Modifier and Type | Class and Description |
|---|---|
static interface |
CommandLine.CommandLineCallback |
| Constructor and Description |
|---|
CommandLine() |
CommandLine(ConfigurationBuilder conf) |
| Modifier and Type | Method and Description |
|---|---|
CommandLine |
addCommandLineOption(org.apache.commons.cli.Option option,
CommandLine.CommandLineCallback cb) |
ConfigurationBuilder |
getBuilder() |
static Configuration |
parseToConfiguration(String[] args,
Class<? extends Name<?>>... argClasses)
Utility method to quickly parse a command line to a Configuration.
|
static ConfigurationBuilder |
parseToConfigurationBuilder(String[] args,
Class<? extends Name<?>>... argClasses)
Utility method to quickly parse a command line to a ConfigurationBuilder.
|
<T> CommandLine |
processCommandLine(String[] args,
Class<? extends Name<?>>... argClasses)
Process command line arguments.
|
CommandLine |
registerShortNameOfClass(Class<? extends Name<?>> c) |
CommandLine |
registerShortNameOfClass(String s) |
public CommandLine()
public CommandLine(ConfigurationBuilder conf)
public ConfigurationBuilder getBuilder()
public CommandLine registerShortNameOfClass(String s) throws BindException
BindExceptionpublic CommandLine registerShortNameOfClass(Class<? extends Name<?>> c) throws BindException
BindExceptionpublic CommandLine addCommandLineOption(org.apache.commons.cli.Option option, CommandLine.CommandLineCallback cb)
@SafeVarargs public final <T> CommandLine processCommandLine(String[] args, Class<? extends Name<?>>... argClasses) throws IOException, BindException
T - a typeargs - the command line arguments to be parsedargClasses - the target named classes to be setIOException - if parsing failsBindException - if a binding of short-named parameter failspublic static Configuration parseToConfiguration(String[] args, Class<? extends Name<?>>... argClasses) throws org.apache.commons.cli.ParseException
This is equivalent to
parseToConfigurationBuilder(args, argClasses).build()
args - the command line parameters to parse.argClasses - the named parameters to look for.org.apache.commons.cli.ParseException - if the parsing of the commandline fails.public static ConfigurationBuilder parseToConfigurationBuilder(String[] args, Class<? extends Name<?>>... argClasses) throws org.apache.commons.cli.ParseException
This is equivalent to
new CommandLine().processCommandLine(args, argClasses).getBuilder(), but with additional checks.
args - the command line parameters to parse.argClasses - the named parameters to look for.org.apache.commons.cli.ParseException - if the parsing of the commandline fails.Copyright © 2017 The Apache Software Foundation. All rights reserved.