Package org.pentaho.di.pan
Class CommandLineOption
java.lang.Object
org.pentaho.di.pan.CommandLineOption
This class allows you to define command-line options.
- Author:
- Matt Casters
-
Constructor Summary
ConstructorDescriptionCommandLineOption
(String option) Creates a new normal command line option without a descriptionCommandLineOption
(String option, String description, StringBuilder argument) Creates a new normal command line optionCommandLineOption
(String option, String description, StringBuilder argument, boolean yesNo, boolean hiddenOption) Creates a new command line option.CommandLineOption
(String option, String description, StringBuilder argument, boolean yesNo, boolean hiddenOption, boolean extraParameter) Creates a new command line option.CommandLineOption
(String option, String description, org.pentaho.di.core.parameters.NamedParams argument, boolean hiddenOption) Creates a new "array" command line option. -
Method Summary
Modifier and TypeMethodDescriptionGets the value of a commandline optionboolean
boolean
boolean
isYesNo()
static boolean
parseArguments
(List<String> args, CommandLineOption[] options, org.pentaho.di.core.logging.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
(StringBuilder argument) void
setDescription
(String description) void
setExtraParameter
(boolean extraParameter) void
setHiddenOption
(boolean hiddenOption) void
void
setYesNo
(boolean yesNo)
-
Constructor Details
-
CommandLineOption
public CommandLineOption(String option, String description, StringBuilder argument, boolean yesNo, boolean hiddenOption) Creates a new command line option.- Parameters:
option
- The option stringdescription
- the description of the optionargument
- the StringBuilder that will contain the argument lateryesNo
- true if this is a Yes/No flaghiddenOption
- true if this option should not be shown in the usage list.
-
CommandLineOption
public CommandLineOption(String option, String description, StringBuilder argument, boolean yesNo, boolean hiddenOption, boolean extraParameter) Creates a new command line option.- Parameters:
option
- The option stringdescription
- the description of the optionargument
- the StringBuilder that will contain the argument lateryesNo
- true if this is a Yes/No flaghiddenOption
- 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, org.pentaho.di.core.parameters.NamedParams argument, boolean hiddenOption) Creates a new "array" command line option.- Parameters:
option
- The option stringdescription
- the description of the optionargument
- the StringBuilder that will contain the argument laterhiddenOption
- true if this option should not be shown in the usage list.
-
CommandLineOption
Creates a new normal command line option- Parameters:
option
- The option stringdescription
- the description of the optionargument
- the StringBuilder that will contain the argument later
-
CommandLineOption
Creates a new normal command line option without a description- Parameters:
option
- The option string
-
-
Method Details
-
getArgument
- Returns:
- Returns the argument.
-
setArgument
- Parameters:
argument
- The argument to set.
-
getOption
- Returns:
- Returns the option.
-
setOption
- 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
- Returns:
- Returns the description.
-
setDescription
- Parameters:
description
- The description to set.
-
getUsageDescription
- Returns:
- the usage description
-
extractAndSetArgument
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, org.pentaho.di.core.logging.LogChannelInterface log) Parse and set the command line arguments using the defined options.- Parameters:
args
- The list of arguments to parseoptions
- The command line options to use
-
isExtraParameter
public boolean isExtraParameter() -
setExtraParameter
public void setExtraParameter(boolean extraParameter) -
printUsage
Print the usage of an application using the command line options.- Parameters:
options
- the options to use
-