fr.umlv.tatoo.cc.common.main
Interface Command<D>

Type Parameters:
D - type of the user data.
All Known Implementing Classes:
AbstractSimpleCommand

public interface Command<D>

Represents a command. A command associate in one place : - a register method to register all options managed by the current command in the OptionRegistry. - a usage of the command - a method execute. First, the method register() is called by the command line parser during its construction (CommandLineParser(prefix,usageFormatter,commands)= or during an addition of commands (addCommand(commands). This method may register some options to the OptionRegistry. When the method parse of CommandLineParser found an option, it calls the method execute(optionName,userData,arguments) of the corresponding command.

Author:
remi

Method Summary
 void execute(String optionName, D userData, List<? extends String> optionArguments)
          Execute the command corresponding to the option.
 void register(OptionRegistry<? extends D> registry)
          Register all options managed by the current command.
 String usage(String optionName, int numberOfArgument)
          Returns the usage of an option represented by the command.
 String usageArgumentName(String optionName, int numberOfArgument, int index)
          Return the name of each argument of an option represented by the command.
 

Method Detail

usage

String usage(String optionName,
             int numberOfArgument)
Returns the usage of an option represented by the command.

Parameters:
optionName - name of the option.
numberOfArgument - number of argument of the option.
Returns:
the usage of the option.

usageArgumentName

String usageArgumentName(String optionName,
                         int numberOfArgument,
                         int index)
Return the name of each argument of an option represented by the command.

Parameters:
optionName - name of the option.
numberOfArgument - number of argument of the option.
index - of the argument index if always between [0,numberOfArgument[
Returns:
the name of the argument

register

void register(OptionRegistry<? extends D> registry)
Register all options managed by the current command.

Parameters:
registry - the option registry.
See Also:
OptionRegistry

execute

void execute(String optionName,
             D userData,
             List<? extends String> optionArguments)
             throws IllegalCommandLineArgumentException
Execute the command corresponding to the option.

Parameters:
optionName - name of the option.
userData - user data.
optionArguments - list of option arguments.
Throws:
IllegalCommandLineArgumentException - if by example optionArguments are bad filled.