java.lang.Object
eu.svjatoslav.commons.cli_helper.parameter_parser.Option<File,DirectoryOption>
eu.svjatoslav.commons.cli_helper.parameter_parser.parameter.DirectoryOption

public class DirectoryOption extends Option<File,DirectoryOption>
Represents a command-line option that accepts exactly one parameter interpreted as a directory path.
  • Constructor Details

    • DirectoryOption

      public DirectoryOption(String description)
      Creates a DirectoryOption object with a specified description.
      Parameters:
      description - a brief description of what this directory option is for.
  • Method Details

    • describeFormat

      public String describeFormat()
      Description copied from class: Option
      Describes the kind or format of the expected parameter(s), e.g. "File", "Integer", etc.
      Specified by:
      describeFormat in class Option<File,DirectoryOption>
      Returns:
      a short string describing the parameter format
    • getValue

      public File getValue()
      Returns the directory as a File object.
      Specified by:
      getValue in class Option<File,DirectoryOption>
      Returns:
      the parsed value as the generic type T.
      Throws:
      RuntimeException - if the user did not provide exactly one parameter.
    • mustExist

      public DirectoryOption mustExist()
      Requires that the directory must already exist.
      Returns:
      this DirectoryOption instance for chaining
    • mustNotExist

      public DirectoryOption mustNotExist()
      Requires that the directory must not already exist.
      Returns:
      this DirectoryOption instance for chaining
    • isValid

      public boolean isValid(String value)
      Checks whether the provided path is valid based on the ExistenceType.
      Specified by:
      isValid in class Option<File,DirectoryOption>
      Parameters:
      value - the directory path to validate
      Returns:
      true if valid, otherwise false