org.pentaho.di.pan
Class CommandLineOption

java.lang.Object
  extended by org.pentaho.di.pan.CommandLineOption

public class CommandLineOption
extends Object

This class allows you to define command-line options.

Author:
Matt Casters

Constructor Summary
CommandLineOption(String option)
          Creates a new normal command line option without a description
CommandLineOption(String option, String description, NamedParams argument, boolean hiddenOption)
          Creates a new "array" command line option.
CommandLineOption(String option, String description, StringBuffer argument)
          Creates a new normal command line option
CommandLineOption(String option, String description, StringBuffer argument, boolean yesNo, boolean hiddenOption)
          Creates a new command line option.
CommandLineOption(String option, String description, StringBuffer argument, boolean yesNo, boolean hiddenOption, boolean extraParameter)
          Creates a new command line option.
 
Method Summary
 String extractAndSetArgument(String arg)
          Gets the value of a commandline option
 StringBuffer getArgument()
           
 String getDescription()
           
 String getOption()
           
 String getUsageDescription()
           
 boolean isExtraParameter()
           
 boolean isHiddenOption()
           
 boolean isYesNo()
           
static boolean parseArguments(List<String> args, CommandLineOption[] options, LogChannelInterface log)
          Parse and set the command line arguments using the defined options.
static void printUsage(CommandLineOption[] options)
          Print the usage of an application using the command line options.
 void setArgument(StringBuffer argument)
           
 void setDescription(String description)
           
 void setExtraParameter(boolean extraParameter)
           
 void setHiddenOption(boolean hiddenOption)
           
 void setOption(String option)
           
 void setYesNo(boolean yesNo)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommandLineOption

public CommandLineOption(String option,
                         String description,
                         StringBuffer argument,
                         boolean yesNo,
                         boolean hiddenOption)
Creates a new command line option.

Parameters:
option - The option string
description - the description of the option
argument - the StringBuffer that will contain the argument later
yesNo - true if this is a Yes/No flag
hiddenOption - true if this option should not be shown in the usage list.

CommandLineOption

public CommandLineOption(String option,
                         String description,
                         StringBuffer argument,
                         boolean yesNo,
                         boolean hiddenOption,
                         boolean extraParameter)
Creates a new command line option.

Parameters:
option - The option string
description - the description of the option
argument - the StringBuffer that will contain the argument later
yesNo - true if this is a Yes/No flag
hiddenOption - true if this option should not be shown in the usage list.
extraParameter - true if this is an extra parameter after the regular options (filenames and so on)

CommandLineOption

public CommandLineOption(String option,
                         String description,
                         NamedParams argument,
                         boolean hiddenOption)
Creates a new "array" command line option.

Parameters:
option - The option string
description - the description of the option
argument - the StringBuffer that will contain the argument later
hiddenOption - true if this option should not be shown in the usage list.

CommandLineOption

public CommandLineOption(String option,
                         String description,
                         StringBuffer argument)
Creates a new normal command line option

Parameters:
option - The option string
description - the description of the option
argument - the StringBuffer that will contain the argument later

CommandLineOption

public CommandLineOption(String option)
Creates a new normal command line option without a description

Parameters:
option - The option string
Method Detail

getArgument

public StringBuffer getArgument()
Returns:
Returns the argument.

setArgument

public void setArgument(StringBuffer argument)
Parameters:
argument - The argument to set.

getOption

public String getOption()
Returns:
Returns the option.

setOption

public void setOption(String option)
Parameters:
option - The option to set.

isYesNo

public boolean isYesNo()
Returns:
Returns wether or not this is a Yes/No flag

setYesNo

public void setYesNo(boolean yesNo)
Parameters:
yesNo - sets wether or not this is a Yes/No flag

getDescription

public String getDescription()
Returns:
Returns the description.

setDescription

public void setDescription(String description)
Parameters:
description - The description to set.

getUsageDescription

public String getUsageDescription()
Returns:
the usage description

extractAndSetArgument

public String extractAndSetArgument(String arg)
Gets the value of a commandline option

Parameters:
arg - The command line argument
Returns:
The value of the commandline option specified.

isHiddenOption

public boolean isHiddenOption()
Returns:
Returns the hiddenOption.

setHiddenOption

public void setHiddenOption(boolean hiddenOption)
Parameters:
hiddenOption - The hiddenOption to set.

parseArguments

public static boolean parseArguments(List<String> args,
                                     CommandLineOption[] options,
                                     LogChannelInterface log)
Parse and set the command line arguments using the defined options.

Parameters:
args - The list of arguments to parse
options - The command line options to use

isExtraParameter

public boolean isExtraParameter()

setExtraParameter

public void setExtraParameter(boolean extraParameter)

printUsage

public static void printUsage(CommandLineOption[] options)
Print the usage of an application using the command line options.

Parameters:
options - the options to use