com.BobCo.cli
Class CliSample

java.lang.Object
  extended bycom.BobCo.cli.CliSample
All Implemented Interfaces:
com.tivoli.twg.engine.cli.ICliBundle

public class CliSample
extends java.lang.Object
implements com.tivoli.twg.engine.cli.ICliBundle

This command line interface (CLI) example shows how to create a bundle extending the command line framework. The steps to creating a bundle are:

(1) implement the ICliBundle interface

(2) use the below method signature for all accessible bundle commands:

  • public int commandName(Locale locale, String[] args, Writer out) throws Exception

    (3) furnish the help method

    The name of the method is used as the name of the command and this is not re-definable.

    When a user executes a command the corresponding method is invoked where:

  • Locale = client locale
  • args = command inputs provided by the user
  • out = output stream back to the client command shell

    This particular bundle example implements two usage/help commands:

  • Help - Displays written help message to the user
  • List - Shows the command syntax

    Two functional commands are implemented as well. One to list all of the subagents for a specified set of systems, and the other to verify a list of service nodes. The commands are below:

  • ListSystemSubAgents
  • CheckServiceNodes

    See Also:
    ICliBundle

    Field Summary
     
    Fields inherited from interface com.tivoli.twg.engine.cli.ICliBundle
    COMMAND_EXCEPTION, FAIL, NOT_FOUND, OK, SECURITY_FAILURE, USAGE
     
    Constructor Summary
    CliSample()
              Default and only constructor
     
    Method Summary
     int checkServiceNodes(java.util.Locale locale, java.lang.String[] args, java.io.Writer out)
              Check for the existance of the named IPC service nodes
     int help(java.util.Locale locale, java.lang.String[] args, java.io.Writer out)
              Mandated bundle command to provide bundle help
     int list(java.util.Locale locale, java.lang.String[] args, java.io.Writer out)
              Bundle command to provide bundle a short/quick command reference
     int listSystemSubAgents(java.util.Locale locale, java.lang.String[] args, java.io.Writer out)
              List the subagents on the given systems
     
    Methods inherited from class java.lang.Object
    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    CliSample

    public CliSample()
    Default and only constructor

    All CLI bundle extensions must have an empty parameter constructor. The constructor can either be ommitted or defined with no parameters

    Method Detail

    help

    public int help(java.util.Locale locale,
                    java.lang.String[] args,
                    java.io.Writer out)
             throws java.lang.Exception
    Mandated bundle command to provide bundle help

    Specified by:
    help in interface com.tivoli.twg.engine.cli.ICliBundle
    Returns:
    int - client application exit code
    Throws:
    java.lang.Exception

    list

    public int list(java.util.Locale locale,
                    java.lang.String[] args,
                    java.io.Writer out)
             throws java.lang.Exception
    Bundle command to provide bundle a short/quick command reference

    Returns:
    int - client application exit code
    Throws:
    java.lang.Exception

    listSystemSubAgents

    public int listSystemSubAgents(java.util.Locale locale,
                                   java.lang.String[] args,
                                   java.io.Writer out)
                            throws java.lang.Exception
    List the subagents on the given systems

    Returns:
    int - client application exit code
    Throws:
    java.lang.Exception

    checkServiceNodes

    public int checkServiceNodes(java.util.Locale locale,
                                 java.lang.String[] args,
                                 java.io.Writer out)
                          throws java.lang.Exception
    Check for the existance of the named IPC service nodes

    Returns:
    int - client application exit code
    Throws:
    java.lang.Exception