ParsedOpts
Mojo struct 🡭
ParsedOpts
@memory_only
struct ParsedOpts
The parsed CLI options. Access your values with ParsedOpts.get_string()
, ParsedOpts.get_int()
, etc.
Access CLI arguments from ParsedOpts.args
.
Get the help message with ParsedOpts.get_help_message
.
Note that there is an automatic help
flag added to your options, it can be overridden by another option with that same name.
The input args are first scanned for “–help” and if that is found the parser will exit early, returning the parsed value of the
“–help” flag (or option if you have overridden it). It is up to the user to check for the “help” option being set and print the
help message.
Fields
- options (
Dict[String, OptValue]
) - args (
List[String]
) - help_msg (
String
)
Implemented traits
AnyType
, Copyable
, ExplicitlyCopyable
, Movable
, UnknownDestructibility
Methods
➕ ➖__init__
fn __init__(out self, var help_msg: String = "")
Details
Args:
- help_msg (
String
) - self (
Self
)
Returns:
Self
get_help_message
fn get_help_message(ref self) -> Pointer[String, self_is_origin.help_msg]
Get a nicely formatted help string.
Args:
- self (
Self
)
Returns:
Pointer
get_string
fn get_string(self, key: String) -> String
Try to get the option specified with the given key as a String.
This will raise if the key is not found, or if the type of the option doesn’t match asked-for type.
Args:
- self (
Self
) - key (
String
)
Returns:
String
Raises:
get_int
fn get_int(self, key: String) -> Int
Try to get the option specified with the given key as an Int.
This will raise if the key is not found, or if the type of the option doesn’t match asked-for type.
Args:
- self (
Self
) - key (
String
)
Returns:
Int
Raises:
get_float
fn get_float(self, key: String) -> SIMD[float64, 1]
Try to get the option specified with the given key as a Float64.
This will raise if the key is not found, or if the type of the option doesn’t match asked-for type.
Args:
- self (
Self
) - key (
String
)
Returns:
SIMD
Raises:
get_bool
fn get_bool(self, key: String) -> Bool
Try to get the option specified with the given key as a Bool.
This will raise if the key is not found, or if the type of the option doesn’t match asked-for type.
Args:
- self (
Self
) - key (
String
)
Returns:
Bool
Raises: