org.crsh.cli.descriptor
Class CommandDescriptor<T>

java.lang.Object
  extended by org.crsh.cli.descriptor.CommandDescriptor<T>
Direct Known Subclasses:
HelpDescriptor, ObjectCommandDescriptor

public abstract class CommandDescriptor<T>
extends Object


Field Summary
private  List<ArgumentDescriptor> arguments
          .
private  Description description
          .
private  boolean listArgument
          .
private  Set<String> longOptionNames
          .
private  String name
          .
private  Map<String,OptionDescriptor> optionMap
          .
private  List<OptionDescriptor> options
          .
private  List<ParameterDescriptor> parameters
          .
private  Set<String> shortOptionNames
          .
private  List<ArgumentDescriptor> uArguments
          .
private  Set<String> uLongOptionNames
          .
private  Map<String,OptionDescriptor> uOptionMap
          .
private  List<OptionDescriptor> uOptions
          .
private  List<ParameterDescriptor> uParameters
          .
private  Set<String> uShortOptionNames
          .
 
Constructor Summary
protected CommandDescriptor(String name, Description description)
           
 
Method Summary
protected  void addParameter(ParameterDescriptor parameter)
          Add a parameter to the command.
 CompletionMatcher<T> completer()
           
 ArgumentDescriptor getArgument(int index)
          Returns a a specified argument by its index.
 List<ArgumentDescriptor> getArguments()
          Returns a list of the command arguments.
 int getDepth()
           
 Description getDescription()
          Returns the command description.
abstract  CommandInvoker<T,?> getInvoker(InvocationMatch<T> match)
           
 Set<String> getLongOptionNames()
          Returns the command long option names.
 String getName()
          Returns the command name.
 OptionDescriptor getOption(String name)
          Returns a command option by its name.
 Set<String> getOptionNames()
          Returns the command option names.
 Collection<OptionDescriptor> getOptions()
          Returns the command options.
abstract  CommandDescriptor<T> getOwner()
           
 List<ParameterDescriptor> getParameters()
          Returns the command parameters, the returned collection contains the command options and the command arguments.
 Set<String> getShortOptionNames()
          Returns the command short option names.
 CommandDescriptor<T> getSubordinate(String name)
          Returns a specified subordinate.
abstract  Map<String,? extends CommandDescriptor<T>> getSubordinates()
           
 String getUsage()
          Returns the command usage, shortcut for invoking getDescription().getUsage() on this object.
 InvocationMatcher<T> matcher()
           
 void print(Format format, Appendable to)
           
 void printMan(Appendable to)
           
 void printUsage(Appendable to)
           
 OptionDescriptor resolveOption(String name)
          Find an command option by its name, this will look through the command hierarchy.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

name

private final String name
.


description

private final Description description
.


optionMap

private final Map<String,OptionDescriptor> optionMap
.


shortOptionNames

private final Set<String> shortOptionNames
.


longOptionNames

private final Set<String> longOptionNames
.


listArgument

private boolean listArgument
.


options

private final List<OptionDescriptor> options
.


arguments

private final List<ArgumentDescriptor> arguments
.


parameters

private final List<ParameterDescriptor> parameters
.


uOptionMap

private final Map<String,OptionDescriptor> uOptionMap
.


uShortOptionNames

private final Set<String> uShortOptionNames
.


uLongOptionNames

private final Set<String> uLongOptionNames
.


uOptions

private final List<OptionDescriptor> uOptions
.


uArguments

private final List<ArgumentDescriptor> uArguments
.


uParameters

private final List<ParameterDescriptor> uParameters
.

Constructor Detail

CommandDescriptor

protected CommandDescriptor(String name,
                            Description description)
                     throws IntrospectionException
Throws:
IntrospectionException
Method Detail

addParameter

protected void addParameter(ParameterDescriptor parameter)
                     throws IntrospectionException,
                            NullPointerException,
                            IllegalArgumentException
Add a parameter to the command.

Parameters:
parameter - the parameter to add
Throws:
IntrospectionException - any introspection exception that would prevent the parameter to be added
NullPointerException - if the parameter is null
IllegalArgumentException - if the parameter is already associated with another command

getOwner

public abstract CommandDescriptor<T> getOwner()

getDepth

public final int getDepth()

printUsage

public final void printUsage(Appendable to)
                      throws IOException
Throws:
IOException

printMan

public final void printMan(Appendable to)
                    throws IOException
Throws:
IOException

print

public final void print(Format format,
                        Appendable to)
                 throws IOException
Throws:
IOException

getSubordinates

public abstract Map<String,? extends CommandDescriptor<T>> getSubordinates()
Returns:
the command subordinates as a map.

getSubordinate

public final CommandDescriptor<T> getSubordinate(String name)
Returns a specified subordinate.

Parameters:
name - the subordinate name
Returns:
the subordinate command or null

getParameters

public final List<ParameterDescriptor> getParameters()
Returns the command parameters, the returned collection contains the command options and the command arguments.

Returns:
the command parameters

getOptionNames

public final Set<String> getOptionNames()
Returns the command option names.

Returns:
the command option names

getShortOptionNames

public final Set<String> getShortOptionNames()
Returns the command short option names.

Returns:
the command long option names

getLongOptionNames

public final Set<String> getLongOptionNames()
Returns the command long option names.

Returns:
the command long option names

getOptions

public final Collection<OptionDescriptor> getOptions()
Returns the command options.

Returns:
the command options

getOption

public final OptionDescriptor getOption(String name)
Returns a command option by its name.

Parameters:
name - the option name
Returns:
the option

resolveOption

public final OptionDescriptor resolveOption(String name)
Find an command option by its name, this will look through the command hierarchy.

Parameters:
name - the option name
Returns:
the option or null

getArguments

public final List<ArgumentDescriptor> getArguments()
Returns a list of the command arguments.

Returns:
the command arguments

getArgument

public final ArgumentDescriptor getArgument(int index)
                                     throws IllegalArgumentException
Returns a a specified argument by its index.

Parameters:
index - the argument index
Returns:
the command argument
Throws:
IllegalArgumentException - if the index is not within the bounds

getName

public final String getName()
Returns the command name.

Returns:
the command name

getDescription

public final Description getDescription()
Returns the command description.

Returns:
the command description

getUsage

public final String getUsage()
Returns the command usage, shortcut for invoking getDescription().getUsage() on this object.

Returns:
the command usage

getInvoker

public abstract CommandInvoker<T,?> getInvoker(InvocationMatch<T> match)

matcher

public final InvocationMatcher<T> matcher()

completer

public final CompletionMatcher<T> completer()


Copyright © 2015 eXo Platform SAS. All Rights Reserved.