net.dpml.cli.option

Class Command

Implemented Interfaces:
Option, Parent

public class Command
extends ParentImpl

Represents a cvs "update" style command line option. Like all Parents, Commands can have child options and can be part of Arguments.
Version:
@PROJECT-VERSION@
Author:
@PUBLISHER-NAME@

Constructor Summary

Command(String preferredName, String description, Set aliases, boolean required, Argument argument, Group children, int id)
Creates a new Command instance.

Method Summary

void
appendUsage(StringBuffer buffer, Set helpSettings, Comparator comp)
Appends usage information to the specified StringBuffer
String
getPreferredName()
The preferred name of an option is used for generating help and usage information.
Set
getTriggers()
Identifies the argument prefixes that should trigger this option.
void
processParent(WriteableCommandLine commandLine, ListIterator arguments)
Process the parent.
void
validate(WriteableCommandLine commandLine)
Checks that the supplied CommandLine is valid with respect to this option.

Methods inherited from class net.dpml.cli.option.ParentImpl

appendUsage, canProcess, defaults, findOption, getArgument, getChildren, getDescription, getPrefixes, helpLines, process, validate

Methods inherited from class net.dpml.cli.option.OptionImpl

canProcess, checkPrefixes, defaults, equals, findOption, getId, hashCode, isRequired, toString

Constructor Details

Command

public Command(String preferredName,
               String description,
               Set aliases,
               boolean required,
               Argument argument,
               Group children,
               int id)
Creates a new Command instance.
Parameters:
preferredName - the name normally used to refer to the Command
description - a description of the Command
aliases - alternative names for the Command
required - true if the Command is required
argument - an Argument that the command takes
children - the Group of child options for this Command
id - a unique id for the Command

Method Details

appendUsage

public void appendUsage(StringBuffer buffer,
                        Set helpSettings,
                        Comparator comp)
Appends usage information to the specified StringBuffer
Specified by:
appendUsage in interface Option
Overrides:
appendUsage in interface ParentImpl
Parameters:
buffer - the buffer to append to
helpSettings - a set of display settings @see DisplaySetting
comp - a comparator used to sort the Options

getPreferredName

public String getPreferredName()
The preferred name of an option is used for generating help and usage information.
Specified by:
getPreferredName in interface Option
Returns:
The preferred name of the option

getTriggers

public Set getTriggers()
Identifies the argument prefixes that should trigger this option. This is used to decide which of many Options should be tried when processing a given argument string. The returned Set must not be null.
Specified by:
getTriggers in interface Option
Returns:
The set of triggers for this Option

processParent

public void processParent(WriteableCommandLine commandLine,
                          ListIterator arguments)
            throws OptionException
Process the parent.
Specified by:
processParent in interface Parent
Parameters:
commandLine - the commandline
arguments - an iterator of arguments
Throws:
OptionException - if an error occurs

validate

public void validate(WriteableCommandLine commandLine)
            throws OptionException
Checks that the supplied CommandLine is valid with respect to this option.
Specified by:
validate in interface Option
Overrides:
validate in interface ParentImpl
Parameters:
commandLine - the CommandLine to check.
Throws:
OptionException - if the CommandLine is not valid.