silk.cli.value.
How a struct field reads its value from the command line.
When to use#
Every field of a command struct needs ArgValue. This module implements it for String,
Bytes, bool, the integer types, Option<T>, and List<T>. Implement it for your own type
to read that type from an argument.
Details#
A bool field is a flag: it takes no value and becomes true when the flag is present. An
Option<T> field becomes present when the option is given. A List<T> field collects every
occurrence, and as a positional argument it takes every remaining argument. A Bytes field
takes the argument's exact bytes, so it also reads a path that is not valid UTF-8; every other
type reads Arg.text, where each byte that is not valid UTF-8 reads as ?.
Import as ArgValue with import silk.cli.value { ArgValue }.
Public declarations: 3.
Arg#
pub struct Arg<'a>One argument, or the part of one after = or after an option letter.
Field text#
pub text: string<'a>The argument as text. Each byte that is not valid UTF-8 reads as ?, so the text has the
same length as bytes.
Field bytes#
pub bytes: &'a [u8]The argument's exact bytes, as the program received them.
Implementation Copy for Arg<'a>#
impl<'a> Copy for Arg<'a>FromArg#
pub interface FromArgA type that reads one value from command-line text.
Operation fromArg#
effect fn fromArg(arg: Arg<'_>) -> Result<Self, bool> ! OutOfMemoryError ? &mut AllocatorReturns the value that arg spells, or false in Result.Failure when it is not a valid
value.
ArgValue#
pub interface ArgValueA field type that the parser can fill from the command line.
Operation takesValue#
fn takesValue() -> boolWhether an occurrence of the option takes a value. false makes the option a flag.
Operation repeats#
fn repeats() -> boolWhether the field accepts more than one occurrence.
Operation initial#
effect fn initial() -> Self ! OutOfMemoryError ? &mut AllocatorReturns the value of a field that the command line does not give: empty text, zero,
false, none, or an empty list.
Operation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool ! OutOfMemoryError ? &mut AllocatorStores one occurrence. arg is empty for a flag. Returns false when it is not a valid
value.
Implementation FromArg for String#
impl FromArg for StringOperation fromArg#
effect fn fromArg(arg: Arg<'_>) -> Result<String, bool>
! OutOfMemoryError
? &mut AllocatorImplementation FromArg for i8#
impl FromArg for i8Operation fromArg#
effect fn fromArg(arg: Arg<'_>) -> Result<i8, bool>
! OutOfMemoryError
? &mut AllocatorImplementation FromArg for i16#
impl FromArg for i16Operation fromArg#
effect fn fromArg(arg: Arg<'_>) -> Result<i16, bool>
! OutOfMemoryError
? &mut AllocatorImplementation FromArg for i32#
impl FromArg for i32Operation fromArg#
effect fn fromArg(arg: Arg<'_>) -> Result<i32, bool>
! OutOfMemoryError
? &mut AllocatorImplementation FromArg for i64#
impl FromArg for i64Operation fromArg#
effect fn fromArg(arg: Arg<'_>) -> Result<i64, bool>
! OutOfMemoryError
? &mut AllocatorImplementation FromArg for u8#
impl FromArg for u8Operation fromArg#
effect fn fromArg(arg: Arg<'_>) -> Result<u8, bool>
! OutOfMemoryError
? &mut AllocatorImplementation FromArg for u16#
impl FromArg for u16Operation fromArg#
effect fn fromArg(arg: Arg<'_>) -> Result<u16, bool>
! OutOfMemoryError
? &mut AllocatorImplementation FromArg for u32#
impl FromArg for u32Operation fromArg#
effect fn fromArg(arg: Arg<'_>) -> Result<u32, bool>
! OutOfMemoryError
? &mut AllocatorImplementation FromArg for u64#
impl FromArg for u64Operation fromArg#
effect fn fromArg(arg: Arg<'_>) -> Result<u64, bool>
! OutOfMemoryError
? &mut AllocatorImplementation FromArg for usize#
impl FromArg for usizeOperation fromArg#
effect fn fromArg(arg: Arg<'_>) -> Result<usize, bool>
! OutOfMemoryError
? &mut AllocatorImplementation FromArg for Bytes#
impl FromArg for BytesOperation fromArg#
effect fn fromArg(arg: Arg<'_>) -> Result<Bytes, bool>
! OutOfMemoryError
? &mut AllocatorImplementation ArgValue for Bytes#
impl ArgValue for BytesOperation takesValue#
fn takesValue() -> boolOperation repeats#
fn repeats() -> boolOperation initial#
effect fn initial() -> Self
! OutOfMemoryError
? &mut AllocatorOperation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool
! OutOfMemoryError
? &mut AllocatorImplementation ArgValue for String#
impl ArgValue for StringOperation takesValue#
fn takesValue() -> boolOperation repeats#
fn repeats() -> boolOperation initial#
effect fn initial() -> Self
! OutOfMemoryError
? &mut AllocatorOperation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool
! OutOfMemoryError
? &mut AllocatorImplementation ArgValue for i8#
impl ArgValue for i8Operation takesValue#
fn takesValue() -> boolOperation repeats#
fn repeats() -> boolOperation initial#
effect fn initial() -> Self
! OutOfMemoryError
? &mut AllocatorOperation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool
! OutOfMemoryError
? &mut AllocatorImplementation ArgValue for i16#
impl ArgValue for i16Operation takesValue#
fn takesValue() -> boolOperation repeats#
fn repeats() -> boolOperation initial#
effect fn initial() -> Self
! OutOfMemoryError
? &mut AllocatorOperation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool
! OutOfMemoryError
? &mut AllocatorImplementation ArgValue for i32#
impl ArgValue for i32Operation takesValue#
fn takesValue() -> boolOperation repeats#
fn repeats() -> boolOperation initial#
effect fn initial() -> Self
! OutOfMemoryError
? &mut AllocatorOperation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool
! OutOfMemoryError
? &mut AllocatorImplementation ArgValue for i64#
impl ArgValue for i64Operation takesValue#
fn takesValue() -> boolOperation repeats#
fn repeats() -> boolOperation initial#
effect fn initial() -> Self
! OutOfMemoryError
? &mut AllocatorOperation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool
! OutOfMemoryError
? &mut AllocatorImplementation ArgValue for u8#
impl ArgValue for u8Operation takesValue#
fn takesValue() -> boolOperation repeats#
fn repeats() -> boolOperation initial#
effect fn initial() -> Self
! OutOfMemoryError
? &mut AllocatorOperation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool
! OutOfMemoryError
? &mut AllocatorImplementation ArgValue for u16#
impl ArgValue for u16Operation takesValue#
fn takesValue() -> boolOperation repeats#
fn repeats() -> boolOperation initial#
effect fn initial() -> Self
! OutOfMemoryError
? &mut AllocatorOperation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool
! OutOfMemoryError
? &mut AllocatorImplementation ArgValue for u32#
impl ArgValue for u32Operation takesValue#
fn takesValue() -> boolOperation repeats#
fn repeats() -> boolOperation initial#
effect fn initial() -> Self
! OutOfMemoryError
? &mut AllocatorOperation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool
! OutOfMemoryError
? &mut AllocatorImplementation ArgValue for u64#
impl ArgValue for u64Operation takesValue#
fn takesValue() -> boolOperation repeats#
fn repeats() -> boolOperation initial#
effect fn initial() -> Self
! OutOfMemoryError
? &mut AllocatorOperation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool
! OutOfMemoryError
? &mut AllocatorImplementation ArgValue for usize#
impl ArgValue for usizeOperation takesValue#
fn takesValue() -> boolOperation repeats#
fn repeats() -> boolOperation initial#
effect fn initial() -> Self
! OutOfMemoryError
? &mut AllocatorOperation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool
! OutOfMemoryError
? &mut AllocatorImplementation ArgValue for bool#
impl ArgValue for boolOperation takesValue#
fn takesValue() -> boolOperation repeats#
fn repeats() -> boolOperation initial#
effect fn initial() -> Self
! OutOfMemoryError
? &mut AllocatorOperation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool
! OutOfMemoryError
? &mut AllocatorImplementation ArgValue for Option<T>#
impl<T: FromArg> ArgValue for Option<T>Operation takesValue#
fn takesValue() -> boolOperation repeats#
fn repeats() -> boolOperation initial#
effect fn initial() -> Self
! OutOfMemoryError
? &mut AllocatorOperation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool
! OutOfMemoryError
? &mut AllocatorImplementation ArgValue for List<T>#
impl<T: FromArg> ArgValue for List<T>Operation takesValue#
fn takesValue() -> boolOperation repeats#
fn repeats() -> boolOperation initial#
effect fn initial() -> Self
! OutOfMemoryError
? &mut AllocatorOperation accept#
effect fn accept(self: &mut Self, arg: Arg<'_>) -> bool
! OutOfMemoryError
? &mut AllocatorCategory: Command line.
Profiles: aarch64-apple-darwin, aarch64-unknown-linux-gnu, aarch64-unknown-linux-gnu-no-libc, x86_64-unknown-linux-gnu, x86_64-unknown-linux-gnu-no-libc, wasm32-unknown-unknown, wasm32-wasip1, wasm32-wasip2, x86_64-pc-windows-msvc, wasm64-unknown-unknown.