pub struct NamedSource<Mode = NoFallback, Shape = Whole, Spelling = Options> { /* private fields */ }Expand description
Takes an argument’s words after its spelling, --long or -s, or from an operand name=value
once .assigned(name) spells it so.
The long spelling defaults to the operation’s argument name with _ written as -. It supplies
one value; .optional(), .many(), and .switch() state another shape.
Implementations§
Source§impl NamedSource
impl NamedSource
Source§impl<Mode> NamedSource<Mode>
impl<Mode> NamedSource<Mode>
Sourcepub fn assigned(self, name: &'static str) -> NamedSource<Mode, Whole, Assigned>
pub fn assigned(self, name: &'static str) -> NamedSource<Mode, Whole, Assigned>
Spells the source as the operand name=value instead of an option: the value is everything
after the first =, and may be empty. It takes no positional place, and no other spelling.
Sourcepub fn switch(self) -> NamedSource<Mode, Switch>
pub fn switch(self) -> NamedSource<Mode, Switch>
Supplies bool: whether the spelling is given, with no value after it.
Sourcepub fn optional_value(self) -> NamedSource<Mode, OptionalValue>
pub fn optional_value(self) -> NamedSource<Mode, OptionalValue>
Supplies Option<Option<_>>: whether the spelling is given, and the value written in its
own word, -i.bak or --in-place=.bak. The next word is never its value.
Source§impl<Mode, Spelling> NamedSource<Mode, Whole, Spelling>
impl<Mode, Spelling> NamedSource<Mode, Whole, Spelling>
Sourcepub fn optional(self) -> NamedSource<Mode, Optional, Spelling>
pub fn optional(self) -> NamedSource<Mode, Optional, Spelling>
Supplies Option of the value: at most one occurrence.
Sourcepub fn many(self) -> NamedSource<Mode, Many, Spelling>
pub fn many(self) -> NamedSource<Mode, Many, Spelling>
Supplies Vec of values: one per occurrence, in order.
Source§impl<Mode, Shape> NamedSource<Mode, Shape>
impl<Mode, Shape> NamedSource<Mode, Shape>
Source§impl<Mode, Shape, Spelling> NamedSource<Mode, Shape, Spelling>
impl<Mode, Shape, Spelling> NamedSource<Mode, Shape, Spelling>
Sourcepub fn env(
self,
name: &'static str,
) -> NamedSource<Mode::WithEnv, Shape, Spelling>where
Mode: EnvFallback,
pub fn env(
self,
name: &'static str,
) -> NamedSource<Mode::WithEnv, Shape, Spelling>where
Mode: EnvFallback,
Reads the environment variable name when the command line gives no words.
Sourcepub fn default(
self,
word: &'static str,
) -> NamedSource<WithFallback, Shape, Spelling>
pub fn default( self, word: &'static str, ) -> NamedSource<WithFallback, Shape, Spelling>
Uses word when neither the command line nor the environment gives one.
Source§impl<Mode, Spelling> NamedSource<Mode, Many, Spelling>
impl<Mode, Spelling> NamedSource<Mode, Many, Spelling>
Sourcepub fn delimiter(self, delimiter: char) -> DelimitedSource<Mode, Spelling>
pub fn delimiter(self, delimiter: char) -> DelimitedSource<Mode, Spelling>
Splits every word, from the command line, the environment, or the default, on delimiter.
Trait Implementations§
impl<Mode, Shape, Spelling> CliNamedSource for NamedSource<Mode, Shape, Spelling>
Source§impl<Decoder, Error> CliSourceDecode<(), Decoder, Error> for NamedSource<NoFallback, Switch>where
Decoder: CliWordsAlg,
impl<Decoder, Error> CliSourceDecode<(), Decoder, Error> for NamedSource<NoFallback, Switch>where
Decoder: CliWordsAlg,
Source§fn cli_decode_source(
&self,
arguments: &mut &[ArgumentInfo],
decoder: &Decoder,
) -> Result<(), CliArgumentError<Error>>
fn cli_decode_source( &self, arguments: &mut &[ArgumentInfo], decoder: &Decoder, ) -> Result<(), CliArgumentError<Error>>
decoder gives for the arguments this source was
described as, taken from the front of arguments. Read moreSource§impl<Value, Decoder, Error> CliSourceDecode<Option<Option<Value>>, Decoder, Error> for NamedSource<NoFallback, OptionalValue>where
Decoder: CliWordsAlg + CliWordAlg<Value, Decoder::Word, Error = Error>,
Decoder::Word: AsRef<OsStr>,
impl<Value, Decoder, Error> CliSourceDecode<Option<Option<Value>>, Decoder, Error> for NamedSource<NoFallback, OptionalValue>where
Decoder: CliWordsAlg + CliWordAlg<Value, Decoder::Word, Error = Error>,
Decoder::Word: AsRef<OsStr>,
Source§fn cli_decode_source(
&self,
arguments: &mut &[ArgumentInfo],
decoder: &Decoder,
) -> Result<Option<Option<Value>>, CliArgumentError<Error>>
fn cli_decode_source( &self, arguments: &mut &[ArgumentInfo], decoder: &Decoder, ) -> Result<Option<Option<Value>>, CliArgumentError<Error>>
decoder gives for the arguments this source was
described as, taken from the front of arguments. Read moreSource§impl<Mode, Value, Decoder, Error, Spelling> CliSourceDecode<Option<Value>, Decoder, Error> for NamedSource<Mode, Optional, Spelling>
impl<Mode, Value, Decoder, Error, Spelling> CliSourceDecode<Option<Value>, Decoder, Error> for NamedSource<Mode, Optional, Spelling>
Source§fn cli_decode_source(
&self,
arguments: &mut &[ArgumentInfo],
decoder: &Decoder,
) -> Result<Option<Value>, CliArgumentError<Error>>
fn cli_decode_source( &self, arguments: &mut &[ArgumentInfo], decoder: &Decoder, ) -> Result<Option<Value>, CliArgumentError<Error>>
decoder gives for the arguments this source was
described as, taken from the front of arguments. Read moreSource§impl<Mode, Value, Decoder, Error, Spelling> CliSourceDecode<Value, Decoder, Error> for NamedSource<Mode, Whole, Spelling>
impl<Mode, Value, Decoder, Error, Spelling> CliSourceDecode<Value, Decoder, Error> for NamedSource<Mode, Whole, Spelling>
Source§fn cli_decode_source(
&self,
arguments: &mut &[ArgumentInfo],
decoder: &Decoder,
) -> Result<Value, CliArgumentError<Error>>
fn cli_decode_source( &self, arguments: &mut &[ArgumentInfo], decoder: &Decoder, ) -> Result<Value, CliArgumentError<Error>>
decoder gives for the arguments this source was
described as, taken from the front of arguments. Read moreSource§impl<Mode, Value, Decoder, Error, Spelling> CliSourceDecode<Vec<Value>, Decoder, Error> for NamedSource<Mode, Many, Spelling>
impl<Mode, Value, Decoder, Error, Spelling> CliSourceDecode<Vec<Value>, Decoder, Error> for NamedSource<Mode, Many, Spelling>
Source§fn cli_decode_source(
&self,
arguments: &mut &[ArgumentInfo],
decoder: &Decoder,
) -> Result<Vec<Value>, CliArgumentError<Error>>
fn cli_decode_source( &self, arguments: &mut &[ArgumentInfo], decoder: &Decoder, ) -> Result<Vec<Value>, CliArgumentError<Error>>
decoder gives for the arguments this source was
described as, taken from the front of arguments. Read moreSource§impl<Decoder, Error> CliSourceDecode<bool, Decoder, Error> for NamedSource<NoFallback, Switch>
impl<Decoder, Error> CliSourceDecode<bool, Decoder, Error> for NamedSource<NoFallback, Switch>
Source§fn cli_decode_source(
&self,
arguments: &mut &[ArgumentInfo],
decoder: &Decoder,
) -> Result<bool, CliArgumentError<Error>>
fn cli_decode_source( &self, arguments: &mut &[ArgumentInfo], decoder: &Decoder, ) -> Result<bool, CliArgumentError<Error>>
decoder gives for the arguments this source was
described as, taken from the front of arguments. Read moreSource§impl<Decoder, Error> CliSourceDecode<bool, Decoder, Error> for NamedSource<WithEnv, Switch>
impl<Decoder, Error> CliSourceDecode<bool, Decoder, Error> for NamedSource<WithEnv, Switch>
Source§fn cli_decode_source(
&self,
arguments: &mut &[ArgumentInfo],
decoder: &Decoder,
) -> Result<bool, CliArgumentError<Error>>
fn cli_decode_source( &self, arguments: &mut &[ArgumentInfo], decoder: &Decoder, ) -> Result<bool, CliArgumentError<Error>>
decoder gives for the arguments this source was
described as, taken from the front of arguments. Read moreSource§impl CliSourceFor<()> for NamedSource<NoFallback, Switch>
An alternative of a sum carrying no value: given by its spelling alone.
impl CliSourceFor<()> for NamedSource<NoFallback, Switch>
An alternative of a sum carrying no value: given by its spelling alone.
Source§fn cli_describe(
&self,
name: &'static str,
positions: &mut usize,
out: &mut Vec<ArgumentInfo>,
)
fn cli_describe( &self, name: &'static str, positions: &mut usize, out: &mut Vec<ArgumentInfo>, )
name into out, counting positional sources in
positions. A compound source describes one argument per part.Source§impl<Value> CliSourceFor<Option<Option<Value>>> for NamedSource<NoFallback, OptionalValue>
An option with a value written only in its own word: absent, given bare, which an interpreter
answers as an empty word, or given a value.
impl<Value> CliSourceFor<Option<Option<Value>>> for NamedSource<NoFallback, OptionalValue>
An option with a value written only in its own word: absent, given bare, which an interpreter answers as an empty word, or given a value.
Source§fn cli_describe(
&self,
name: &'static str,
positions: &mut usize,
out: &mut Vec<ArgumentInfo>,
)
fn cli_describe( &self, name: &'static str, positions: &mut usize, out: &mut Vec<ArgumentInfo>, )
name into out, counting positional sources in
positions. A compound source describes one argument per part.Source§impl<Mode, Value, Spelling: CliSpelling> CliSourceFor<Option<Value>> for NamedSource<Mode, Optional, Spelling>
impl<Mode, Value, Spelling: CliSpelling> CliSourceFor<Option<Value>> for NamedSource<Mode, Optional, Spelling>
Source§fn cli_describe(
&self,
name: &'static str,
positions: &mut usize,
out: &mut Vec<ArgumentInfo>,
)
fn cli_describe( &self, name: &'static str, positions: &mut usize, out: &mut Vec<ArgumentInfo>, )
name into out, counting positional sources in
positions. A compound source describes one argument per part.Source§impl<Mode, Value, Spelling: CliSpelling> CliSourceFor<Value> for NamedSource<Mode, Whole, Spelling>
impl<Mode, Value, Spelling: CliSpelling> CliSourceFor<Value> for NamedSource<Mode, Whole, Spelling>
Source§fn cli_describe(
&self,
name: &'static str,
positions: &mut usize,
out: &mut Vec<ArgumentInfo>,
)
fn cli_describe( &self, name: &'static str, positions: &mut usize, out: &mut Vec<ArgumentInfo>, )
name into out, counting positional sources in
positions. A compound source describes one argument per part.Source§impl<Mode, Value, Spelling: CliSpelling> CliSourceFor<Vec<Value>> for NamedSource<Mode, Many, Spelling>
impl<Mode, Value, Spelling: CliSpelling> CliSourceFor<Vec<Value>> for NamedSource<Mode, Many, Spelling>
Source§fn cli_describe(
&self,
name: &'static str,
positions: &mut usize,
out: &mut Vec<ArgumentInfo>,
)
fn cli_describe( &self, name: &'static str, positions: &mut usize, out: &mut Vec<ArgumentInfo>, )
name into out, counting positional sources in
positions. A compound source describes one argument per part.Source§impl CliSourceFor<bool> for NamedSource<NoFallback, Switch>
impl CliSourceFor<bool> for NamedSource<NoFallback, Switch>
Source§fn cli_describe(
&self,
name: &'static str,
positions: &mut usize,
out: &mut Vec<ArgumentInfo>,
)
fn cli_describe( &self, name: &'static str, positions: &mut usize, out: &mut Vec<ArgumentInfo>, )
name into out, counting positional sources in
positions. A compound source describes one argument per part.Source§impl CliSourceFor<bool> for NamedSource<WithEnv, Switch>
impl CliSourceFor<bool> for NamedSource<WithEnv, Switch>
Source§fn cli_describe(
&self,
name: &'static str,
positions: &mut usize,
out: &mut Vec<ArgumentInfo>,
)
fn cli_describe( &self, name: &'static str, positions: &mut usize, out: &mut Vec<ArgumentInfo>, )
name into out, counting positional sources in
positions. A compound source describes one argument per part.Source§impl<Mode: Clone, Shape: Clone, Spelling: Clone> Clone for NamedSource<Mode, Shape, Spelling>
impl<Mode: Clone, Shape: Clone, Spelling: Clone> Clone for NamedSource<Mode, Shape, Spelling>
impl<Mode: Copy, Shape: Copy, Spelling: Copy> Copy for NamedSource<Mode, Shape, Spelling>
Auto Trait Implementations§
impl<Mode, Shape, Spelling> Freeze for NamedSource<Mode, Shape, Spelling>
impl<Mode, Shape, Spelling> RefUnwindSafe for NamedSource<Mode, Shape, Spelling>
impl<Mode, Shape, Spelling> Send for NamedSource<Mode, Shape, Spelling>
impl<Mode, Shape, Spelling> Sync for NamedSource<Mode, Shape, Spelling>
impl<Mode, Shape, Spelling> Unpin for NamedSource<Mode, Shape, Spelling>
impl<Mode, Shape, Spelling> UnsafeUnpin for NamedSource<Mode, Shape, Spelling>
impl<Mode, Shape, Spelling> UnwindSafe for NamedSource<Mode, Shape, Spelling>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<This> CliDeclarationLawsExt<This> for This
impl<This> CliDeclarationLawsExt<This> for This
Source§fn law_cli_declaration<Operation, Sources, Mode, Commands>(
&self,
name: &'static str,
operation: Operation,
sources: Sources,
mode: Mode,
conventions: Conventions,
) -> Result<(), &'static str>where
This: CliOperationAlg<Operation, Sources, Mode, Commands = Commands> + CliCommandsObserved<Commands = Commands>,
Operation: OperationAlg,
Sources: CliSources<<Operation as OperationAlg>::Args>,
fn law_cli_declaration<Operation, Sources, Mode, Commands>(
&self,
name: &'static str,
operation: Operation,
sources: Sources,
mode: Mode,
conventions: Conventions,
) -> Result<(), &'static str>where
This: CliOperationAlg<Operation, Sources, Mode, Commands = Commands> + CliCommandsObserved<Commands = Commands>,
Operation: OperationAlg,
Sources: CliSources<<Operation as OperationAlg>::Args>,
Checks that operation declared under name with sources describes exactly that, with
one argument per operation argument, in order, and distinct spellings and positions.
Source§impl<This> CliOutcomeLawsExt<This> for This
impl<This> CliOutcomeLawsExt<This> for This
Source§impl<This> CliProgramExt<This> for This
impl<This> CliProgramExt<This> for This
Source§fn compile_cli<Program>(
&self,
program: Program,
) -> <Program as CliProgramAlg<This>>::Commandswhere
Program: CliProgramAlg<This>,
fn compile_cli<Program>(
&self,
program: Program,
) -> <Program as CliProgramAlg<This>>::Commandswhere
Program: CliProgramAlg<This>,
Compiles a named CLI program with this interpreter.
impl<Source, Args, const INDEX: usize> CliSourceAt<Args, INDEX> for Source
impl<Source> CliStatedFor<ContextArg> for Source
impl<Source, Arg> CliStatedFor<StatedArg<Arg>> for Sourcewhere
Source: CliSourceFor<Arg>,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<This> ShapeProgramExt<This> for This
impl<This> ShapeProgramExt<This> for This
Source§fn compile_shape<Program>(
&self,
program: Program,
) -> <Program as ShapeProgramAlg<This>>::Tywhere
Program: ShapeProgramAlg<This>,
fn compile_shape<Program>(
&self,
program: Program,
) -> <Program as ShapeProgramAlg<This>>::Tywhere
Program: ShapeProgramAlg<This>,
Folds a declaration with this interpretation.