public abstract class AbstractCli extends Object
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.logging.Log |
logger
Log.
|
protected static String |
OPT_DSMLV1
Option for dsmlv1 output.
|
protected static String |
OPT_DSMLV2
Option for dsmlv2 output.
|
protected static String |
OPT_HELP
Option to print usage.
|
protected static String |
OPT_TRACE
Option for ldap trace.
|
protected static String |
OPT_USE_PROPERTIES
Option for loading ldap configuration from properties.
|
protected org.apache.commons.cli.Options |
options
Command line options.
|
protected List<String> |
opts
List of command options.
|
protected boolean |
outputDsmlv1
Whether to output dsml version 1, the default is ldif.
|
protected boolean |
outputDsmlv2
Whether to output dsml version 2, the default is ldif.
|
Constructor and Description |
---|
AbstractCli()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract void |
dispatch(org.apache.commons.cli.CommandLine line)
Dispatch command line data to the handler that can perform the operation
requested on the command line.
|
protected Map<String,String> |
getArgs()
Returns the command line arguments for this cli.
|
protected abstract String |
getCommandName()
Gets the name of the command for which this class provides a CLI interface.
|
protected void |
initLdapProperties(PropertyConfig config,
org.apache.commons.cli.CommandLine line)
Initialize the supplied config with command line options.
|
protected abstract void |
initOptions()
Initialize CLI options.
|
protected void |
initOptions(LdapConfigPropertyInvoker invoker)
Initialize CLI options with the supplied invoker.
|
void |
performAction(String[] args)
Parses command line options and invokes the proper handler to perform the
requested action, or the default action if no action is specified.
|
protected void |
printExamples()
Prints CLI usage examples.
|
protected void |
printHelp()
Prints CLI help text.
|
protected static final String OPT_HELP
protected static final String OPT_TRACE
protected static final String OPT_USE_PROPERTIES
protected static final String OPT_DSMLV1
protected static final String OPT_DSMLV2
protected final org.apache.commons.logging.Log logger
protected org.apache.commons.cli.Options options
protected boolean outputDsmlv1
protected boolean outputDsmlv2
public final void performAction(String[] args)
args
- Command line arguments.protected abstract void initOptions()
protected void initOptions(LdapConfigPropertyInvoker invoker)
invoker
- PropertyInvoker
protected abstract String getCommandName()
protected abstract void dispatch(org.apache.commons.cli.CommandLine line) throws Exception
line
- Parsed command line arguments container.Exception
- On errors thrown by handler.protected void printHelp()
protected void printExamples()
protected Map<String,String> getArgs()
protected void initLdapProperties(PropertyConfig config, org.apache.commons.cli.CommandLine line) throws Exception
config
- property config to configureline
- Parsed command line arguments container.Exception
- On errors thrown by handler.Copyright © 2018. All rights reserved.