OptValue

Mojo struct 🡭

OptValue

@memory_only
struct OptValue

When an option is parsed, it’s stored as an OptValue.

To get concrete values out of the ParsedOpts prefer to use the ParsedOpts.get_<type>() methods.

Fields

  • kind (OptKind)

Implemented traits

AnyType, Copyable, Deinitable, Movable

Methods

 

__init__

def __init__(out self, str_value: String = "")

DetailsArgs:

  • str_value (String)
  • self (Self)

Returns:

Self

def __init__(out self, int_value: Int = Int(0))

DetailsArgs:

  • int_value (Int)
  • self (Self)

Returns:

Self

def __init__(out self, float_value: Float64 = 0)

DetailsArgs:

  • float_value (Float64)
  • self (Self)

Returns:

Self

def __init__(out self, bool_value: Bool = False)

DetailsArgs:

  • bool_value (Bool)
  • self (Self)

Returns:

Self

get_string

def get_string(self) -> Optional[String]

DetailsArgs:

  • self (Self)

Returns:

Optional[String]

get_int

def get_int(self) -> Optional[Int]

DetailsArgs:

  • self (Self)

Returns:

Optional[Int]

get_float

def get_float(self) -> Optional[Float64]

DetailsArgs:

  • self (Self)

Returns:

Optional[Float64]

get_bool

def get_bool(self) -> Optional[Bool]

DetailsArgs:

  • self (Self)

Returns:

Optional[Bool]

parse_string

@staticmethod
def parse_string(value: String) -> Self

DetailsArgs:

  • value (String)

Returns:

Self

parse_int

@staticmethod
def parse_int(value: String) -> Self

DetailsArgs:

  • value (String)

Returns:

Self

Raises:

parse_float

@staticmethod
def parse_float(value: String) -> Self

DetailsArgs:

  • value (String)

Returns:

Self

Raises:

parse_bool

@staticmethod
def parse_bool(value: String) -> Self

DetailsArgs:

  • value (String)

Returns:

Self

Raises:

parse_kind

@staticmethod
def parse_kind(kind: OptKind, value: String) -> Self

Parse the string based on the value of OptKind.Args:

  • kind (OptKind)
  • value (String)

Returns:

Self

Raises: