com.frugalmechanic.optparse

StrOpt

class StrOpt extends ArgOpt[String] with SingleOpt[String]

A command line option that takes a string argument

Examples

object MyApp extends OptParse {
// Basic string argument using a default long name of --name and short name of -n
val name = StrOpt()

// Example with all available options instead of relying on the defaults
val message = BoolOpt(
   long="message",          // Long name to use (--message)
   short="m",               // Short name to use (-m)
   default="Hello",         // Default value
   desc="Message to print", // Help message description
   enables=Nil,             // Other flags to enable if this one is enabled (single option or a Seq of options)
   disables=Nil,            // Other flags to disable if this one is enabled (single option or a Seq of options)
   invalidWith=Nil,         // Other options this flag is invalid with (they cannot be set)
   validWith=Nil,           // Other options that are required with this flag
   exclusive=false,         // Other options can be set when this option is set
   validate="^[a-zA-Z ,]+$" // Use a regex for validation via an implicit that converts it to: (String) => Boolean
)

def main(args:Array[String]) {
  parse(args)

  // getOrElse is available via an implicit from OptVal to Option[String]
  println(message+" "+name.getOrElse("Anonymous"))
}
}
Linear Supertypes
SingleOpt[String], ArgOpt[String], OptVal[String], Opt, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. StrOpt
  2. SingleOpt
  3. ArgOpt
  4. OptVal
  5. Opt
  6. AnyRef
  7. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new StrOpt(long: Option[String], short: Option[Char], default: Option[String], desc: String, enables: ⇒ Seq[BoolOpt], disables: ⇒ Seq[BoolOpt], invalidWith: ⇒ Seq[Opt], validWith: ⇒ Seq[Opt], exclusive: Boolean, validate: (String) ⇒ Boolean)

    long

    Long name for this option (--long_name on the command line)

    short

    Short name for this option (-short_name on the command line)

    default

    Default value for this option

    desc

    Description of the parameter (used in help message)

    enables

    Other flags that this option implicitly enables

    disables

    Other flags that this option implicitly disables

    invalidWith

    Other options that this option is not valid with

    validWith

    Other options that are required to be set when using this options

    exclusive

    Whether or not this option is exclusive and cannot be used with any other options (e.g. like --help where it prints the help message and exits)

    validate

    A method that takes the String value and returns a boolean indicating if the argument value is valid

Type Members

  1. type Elem = String

    Definition Classes
    SingleOpt

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. var actualLong: Option[String]

    Attributes
    protected[com.frugalmechanic.optparse]
    Definition Classes
    Opt
  7. var actualShort: Option[Char]

    Attributes
    protected[com.frugalmechanic.optparse]
    Definition Classes
    Opt
  8. def apply(): String

    Get the value

    Get the value

    This calls Option.get on the underlying value so an exception will be thrown if the value is not set.

    Definition Classes
    OptVal
  9. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  10. def clone(): AnyRef

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @throws( ... )
  11. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  12. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  13. final def getClass(): Class[_]

    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  14. def hashCode(): Int

    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  15. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  16. var methodName: String

    Attributes
    protected[com.frugalmechanic.optparse]
    Definition Classes
    Opt
  17. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  18. final def notify(): Unit

    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  19. final def notifyAll(): Unit

    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  20. def parseValue(v: String): String

    A no-op default parsing method

    A no-op default parsing method

    Definition Classes
    StrOptArgOpt
  21. def reset(): Unit

    Reset the value to the default

    Reset the value to the default

    Definition Classes
    OptValOpt
  22. def setValue(arg: String): Unit

    Definition Classes
    SingleOpt
  23. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  24. def toString(): String

    Definition Classes
    AnyRef → Any
  25. def validate(value: String): Boolean

    Validate the parsed value using the validate argument passed in on the constructor

    Validate the parsed value using the validate argument passed in on the constructor

    Definition Classes
    ArgOpt
  26. def value: Option[String]

    The value attached to this command line option (wrapped in an Option)

    The value attached to this command line option (wrapped in an Option)

    Definition Classes
    OptVal
  27. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  28. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  29. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): Unit

    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @Deprecated @deprecated @throws( classOf[java.lang.Throwable] )
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from SingleOpt[String]

Inherited from ArgOpt[String]

Inherited from OptVal[String]

Inherited from Opt

Inherited from AnyRef

Inherited from Any

Ungrouped