org.ldaptive.cli
Class AbstractCli

java.lang.Object
  extended by org.ldaptive.cli.AbstractCli
Direct Known Subclasses:
AddOperationCli, AuthenticatorCli, CompareOperationCli, DeleteOperationCli, SearchOperationCli

public abstract class AbstractCli
extends Object

Abstract base class for all CLI classes.

Version:
$Revision: 3066 $ $Date: 2014-10-16 12:23:27 -0400 (Thu, 16 Oct 2014) $
Author:
Middleware Services

Field Summary
protected static String OPT_HELP
          option to print usage.
protected static String OPT_PROVIDER_PROPERTIES
          option for provider properties.
protected  org.apache.commons.cli.Options options
          command line options.
protected  boolean outputDsmlv1
          whether to output dsml version 1, the default is ldif.
 
Constructor Summary
AbstractCli()
           
 
Method Summary
protected abstract  int dispatch(org.apache.commons.cli.CommandLine line)
          Dispatch command line data to the active that can perform the operation requested on the command line.
protected  Map<String,String> getArgDesc(Class<?>... classes)
          Returns the command line argument descriptions for this CLI.
protected abstract  String getCommandName()
          Returns the name of the command for which this class provides a CLI interface.
protected  Properties getPropertiesFromOptions(String domain, org.apache.commons.cli.CommandLine line)
          Reads the options from the supplied command line and returns a properties containing those options.
protected  ConnectionFactory initConnectionFactory(org.apache.commons.cli.CommandLine line)
          Initialize a connection factory with command line options.
protected  void initOptions()
          Initialize CLI options.
 int performAction(String[] args)
          Parses command line options and dispatches to 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OPT_HELP

protected static final String OPT_HELP
option to print usage.

See Also:
Constant Field Values

OPT_PROVIDER_PROPERTIES

protected static final String OPT_PROVIDER_PROPERTIES
option for provider properties.

See Also:
Constant Field Values

options

protected final org.apache.commons.cli.Options options
command line options.


outputDsmlv1

protected boolean outputDsmlv1
whether to output dsml version 1, the default is ldif.

Constructor Detail

AbstractCli

public AbstractCli()
Method Detail

performAction

public final int performAction(String[] args)
Parses command line options and dispatches to the requested action, or the default action if no action is specified.

Parameters:
args - command line arguments
Returns:
status code

initOptions

protected void initOptions()
Initialize CLI options.


initConnectionFactory

protected ConnectionFactory initConnectionFactory(org.apache.commons.cli.CommandLine line)
Initialize a connection factory with command line options.

Parameters:
line - parsed command line arguments
Returns:
connection factory that has been initialized

getCommandName

protected abstract String getCommandName()
Returns the name of the command for which this class provides a CLI interface.

Returns:
name of CLI command

dispatch

protected abstract int dispatch(org.apache.commons.cli.CommandLine line)
                         throws Exception
Dispatch command line data to the active that can perform the operation requested on the command line.

Parameters:
line - parsed command line arguments
Returns:
status code
Throws:
Exception - on errors thrown by action

printHelp

protected void printHelp()
Prints CLI help text.


printExamples

protected void printExamples()
Prints CLI usage examples.


getArgDesc

protected Map<String,String> getArgDesc(Class<?>... classes)
Returns the command line argument descriptions for this CLI.

Parameters:
classes - that contain arguments used by this CLI
Returns:
map of argument name to description

getPropertiesFromOptions

protected Properties getPropertiesFromOptions(String domain,
                                              org.apache.commons.cli.CommandLine line)
Reads the options from the supplied command line and returns a properties containing those options.

Parameters:
domain - to place property names in
line - command line
Returns:
properties for each option and value


Copyright © 2003-2017 Virginia Tech. All Rights Reserved.