public class CommandLineOption extends Object
Constructor and Description |
---|
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,
StringBuilder argument)
Creates a new normal command line option
|
CommandLineOption(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.
|
Modifier and Type | Method and Description |
---|---|
String |
extractAndSetArgument(String arg)
Gets the value of a commandline option
|
StringBuilder |
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(StringBuilder argument) |
void |
setDescription(String description) |
void |
setExtraParameter(boolean extraParameter) |
void |
setHiddenOption(boolean hiddenOption) |
void |
setOption(String option) |
void |
setYesNo(boolean yesNo) |
public CommandLineOption(String option, String description, StringBuilder argument, boolean yesNo, boolean hiddenOption)
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.public CommandLineOption(String option, String description, StringBuilder argument, boolean yesNo, boolean hiddenOption, boolean extraParameter)
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)public CommandLineOption(String option, String description, NamedParams argument, boolean hiddenOption)
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.public CommandLineOption(String option, String description, StringBuilder argument)
option
- The option stringdescription
- the description of the optionargument
- the StringBuilder that will contain the argument laterpublic CommandLineOption(String option)
option
- The option stringpublic StringBuilder getArgument()
public void setArgument(StringBuilder argument)
argument
- The argument to set.public String getOption()
public void setOption(String option)
option
- The option to set.public boolean isYesNo()
public void setYesNo(boolean yesNo)
yesNo
- sets wether or not this is a Yes/No flagpublic String getDescription()
public void setDescription(String description)
description
- The description to set.public String getUsageDescription()
public String extractAndSetArgument(String arg)
arg
- The command line argumentpublic boolean isHiddenOption()
public void setHiddenOption(boolean hiddenOption)
hiddenOption
- The hiddenOption to set.public static boolean parseArguments(List<String> args, CommandLineOption[] options, LogChannelInterface log)
args
- The list of arguments to parseoptions
- The command line options to usepublic boolean isExtraParameter()
public void setExtraParameter(boolean extraParameter)
public static void printUsage(CommandLineOption[] options)
options
- the options to useCopyright © 2018 Hitachi Vantara. All rights reserved.