Class CommandLineOption

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

public class CommandLineOption extends Object
This class allows you to define command-line options.
Author:
Matt Casters
  • 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 string
      description - the description of the option
      argument - the StringBuilder 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, StringBuilder 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 StringBuilder 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, org.pentaho.di.core.parameters.NamedParams argument, boolean hiddenOption)
      Creates a new "array" command line option.
      Parameters:
      option - The option string
      description - the description of the option
      argument - the StringBuilder 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, StringBuilder argument)
      Creates a new normal command line option
      Parameters:
      option - The option string
      description - the description of the option
      argument - the StringBuilder 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 Details

    • getArgument

      public StringBuilder getArgument()
      Returns:
      Returns the argument.
    • setArgument

      public void setArgument(StringBuilder 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, 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 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