CommandLineError variantv0.1.0
pub variant CommandLineError {
UnknownOption(OsStringView),
MissingValue(char8[..]),
UnexpectedValue(char8[..]),
UnknownCommand(OsStringView),
MissingCommand,
MissingPositional(char8[..]),
UnexpectedArgument(OsStringView),
InvalidValue(char8[..], OsStringView)
}
Failure-only: a parse is the success channel of Parsed ! CommandLineError. Copy; every view and name it carries
borrows the arguments or the specification, which must outlive it.
Cases
| Name | Description |
|---|---|
UnknownOption(OsStringView) | An argument that looks like an option names none the command has. Carries the argument as typed. |
MissingValue(char8[..]) | An option that takes a value was the last argument, or ended a cluster of short options. Carries the option's long name. |
UnexpectedValue(char8[..]) | A flag was given a value with =. Carries the option's long name. |
UnknownCommand(OsStringView) | The command has subcommands and the word naming one is not among them. Carries the word as typed. |
MissingCommand | The command has subcommands and none was named. |
MissingPositional(char8[..]) | A required positional argument was not given. Carries its name. |
UnexpectedArgument(OsStringView) | A positional argument beyond every one the command accepts. Carries the argument as typed. |
InvalidValue(char8[..], OsStringView) | A value that could not be read as what was asked of it, such as a number. Carries the option or positional's name, then the value as typed. |
Implements Display
CommandLineError conforms to Display.
WriteDisplay
pub func WriteDisplay(
self: &CommandLineError,
writer: &var TextWriter,
spec: FormatSpec
) -> ! FormatError
Writes what went wrong, naming the argument, option or positional involved.
The text is lower case without a final full stop, such as unknown option '--frob' or
option '--output' needs a value. No style is understood. Reports whatever the writer reported, and
UnsupportedRequest for a style.
| Name | Type | Description |
|---|---|---|
writer | &var TextWriter | the destination |
spec | FormatSpec | what the placeholder asked for |
Returns: success when the whole description was accepted
Implements Debug
CommandLineError conforms to Debug.
WriteDebug
pub func WriteDebug(
self: &CommandLineError,
writer: &var TextWriter,
spec: FormatSpec
) -> ! FormatError
The same text as Display: the description already names everything involved.
The failures WriteDisplay reports.
| Name | Type | Description |
|---|---|---|
writer | &var TextWriter | the destination |
spec | FormatSpec | what the placeholder asked for |
Returns: success when the whole description was accepted