Class CommandLineImpl

java.lang.Object
org.flasby.cli.impl.CommandLineImpl
All Implemented Interfaces:
CommandLine

public class CommandLineImpl extends Object implements CommandLine
Author:
flasbyst
  • Constructor Details

  • Method Details

    • wasProvided

      public boolean wasProvided(Option option)
      Description copied from interface: CommandLine
      informs if the specified Option was provided on the commandline. Note that missing or unknown arguments will be flagged by a suitable exception.
      Specified by:
      wasProvided in interface CommandLine
      Parameters:
      option -
      Returns:
    • getValues

      public String[] getValues(OptionList option)
      Description copied from interface: CommandLine
      returns an array of values containing all the values provided for this option. If the option was specified 3 times, then this array could be up to length 3. Note that if only 2 out of the three options actually provided a value, then this array will only have a length of 2. It will never return null. The values will be returned in the order encountered on the command line.
      Specified by:
      getValues in interface CommandLine
      Parameters:
      option -
      Returns:
      an array of all the values provided on the command line for this option.
    • getValue

      public String getValue(Option option)
      Description copied from interface: CommandLine
      returns the value of the option, if any. If the option was provided more than once and a value was provided more than once then this will return the first one provided.
      Specified by:
      getValue in interface CommandLine
      Parameters:
      option - - the option value required.
      Returns:
      null if the option was not provided or no value for the option was provided, otherwise the actual value of the option.
    • getValue

      public boolean getValue(Flag flag)
      Description copied from interface: CommandLine
      returns the value of the flag. That is, was the flag provided on the commandline.
      Specified by:
      getValue in interface CommandLine
      Parameters:
      flag -
      Returns:
    • wasDefaultProvided

      public boolean wasDefaultProvided()
      Description copied from interface: CommandLine
      informs if a default Option was provided on the commandline. By default I mean a value with no option flag, or one preceeded by '- '.
      Specified by:
      wasDefaultProvided in interface CommandLine
      Returns:
    • getDefaultValue

      public String getDefaultValue()
      Description copied from interface: CommandLine
      returns the value of the default, if any. If the default value was provided more than once and then this will return the first one provided.
      Specified by:
      getDefaultValue in interface CommandLine
      Returns:
      null if no default value was provided otherwise the actual value of the option.
    • getDefaultValues

      public String[] getDefaultValues()
      Description copied from interface: CommandLine
      returns an array of values containing all the values provided as defaults. That is, all values provided without a prceeding option or preceeded by a '- '. It will never return null. The values will be returned in the order encountered on the command line.
      Specified by:
      getDefaultValues in interface CommandLine
      Returns:
      an array of all the values provided on the command line for this option.
    • getOptions

      public Options getOptions()
      Description copied from interface: CommandLine
      returns all the options parsed by this commandline instance.
      Specified by:
      getOptions in interface CommandLine
      Returns: