Skip to main content

Operation

Struct Operation 

Source
pub struct Operation<Handler, Inputs = (), Mode = Total> { /* private fields */ }
Expand description

Carries a typed operation, the sources of its arguments (one per argument, in order), and how its output is read as the command’s outcome.

Implementations§

Source§

impl<Handler, Inputs, Mode> Operation<Handler, Inputs, Mode>

Source

pub fn arg<Source>( self, name: &'static str, source: Source, ) -> Operation<Handler, (Inputs, Source), Mode>

Declares the source of the operation’s next argument, the one named name, after those already declared.

defunc(via = cli) checks the name against the operation’s own when the program compiles, reporting a source written for another argument where it is written.

Source

pub fn declare(self, name: &'static str) -> Command<Handler, Inputs, Mode>

Declares this operation under one command name, with no program around it.

A program that states many commands composes their registrations rather than their types, so it needs each command on its own. CliProgram::cmd states the same thing inside a composition, and is what an author writes.

Source§

impl<Handler, Inputs, Mode> Operation<Handler, Inputs, Mode>

Source

pub fn options_first(self) -> Self

Ends the command’s options at its first operand.

Source

pub fn unknown_options_as_operands(self) -> Self

Reads a word naming no option of the command as an operand.

Source

pub fn no_end_of_options(self) -> Self

Reads -- as an operand rather than the end of the options.

Source

pub fn numeric_option(self, long: &'static str) -> Self

Reads a word of a dash and digits as the option spelled --long given those digits, as head -5 is head -n 5.

Source

pub fn verbatim(self) -> Self

Reads every word as an operand, ignores operands beyond the command’s own, and answers no help.

Source

pub fn within<Program>( self, program: CliProgram<Program>, ) -> Within<Handler, Inputs, Mode, Program>

Applies every command of program to the context this operation answers, with no program around it.

Source§

impl<Handler, Inputs> Operation<Handler, Inputs, Total>

Source

pub fn fallible(self) -> Operation<Handler, Inputs, Fallible>

Reads the operation’s Result output as success or a failure exiting with status 1. The error can be any error that displays, anyhow::Error among them.

Source

pub fn fallible_as(self, status: u8) -> Operation<Handler, Inputs, Fallible>

Reads the operation’s Result output as success or a failure exiting with status.

§Panics

Panics when status is zero, which is success.

Source

pub fn fallible_by_error(self) -> Operation<Handler, Inputs, FallibleByError>

Reads the operation’s Result output as success or a failure with the status its error states through CliFailureAlg, which may also say it was reported as it happened.

Trait Implementations§

Source§

impl<Handler: Debug, Inputs: Debug, Mode: Debug> Debug for Operation<Handler, Inputs, Mode>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<Handler, Inputs, Mode> Freeze for Operation<Handler, Inputs, Mode>
where Handler: Freeze, Inputs: Freeze, Mode: Freeze,

§

impl<Handler, Inputs, Mode> RefUnwindSafe for Operation<Handler, Inputs, Mode>
where Handler: RefUnwindSafe, Inputs: RefUnwindSafe, Mode: RefUnwindSafe,

§

impl<Handler, Inputs, Mode> Send for Operation<Handler, Inputs, Mode>
where Handler: Send, Inputs: Send, Mode: Send,

§

impl<Handler, Inputs, Mode> Sync for Operation<Handler, Inputs, Mode>
where Handler: Sync, Inputs: Sync, Mode: Sync,

§

impl<Handler, Inputs, Mode> Unpin for Operation<Handler, Inputs, Mode>
where Handler: Unpin, Inputs: Unpin, Mode: Unpin,

§

impl<Handler, Inputs, Mode> UnsafeUnpin for Operation<Handler, Inputs, Mode>
where Handler: UnsafeUnpin, Inputs: UnsafeUnpin, Mode: UnsafeUnpin,

§

impl<Handler, Inputs, Mode> UnwindSafe for Operation<Handler, Inputs, Mode>
where Handler: UnwindSafe, Inputs: UnwindSafe, Mode: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

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>,

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

Source§

fn law_cli_outcome<Output>(&self, output: Output) -> Result<(), &'static str>
where This: CliOutcomeOf<Output>, <This as CliOutcomeOf<Output>>::Error: CliFailureAlg,

Checks that output read under this mode exits with zero exactly when it succeeds.

Source§

impl<Source> CliPartsFor<ContextArg> for Source

Source§

const PARTS: &'static [&'static str] = const PARTS: &'static [&'static str] = &[];

The argument’s part names, in order.
Source§

const PART: &'static str = const PART: &'static str = "part";

What one part is called: field or alternative.
Source§

const WHOLE: &'static str = const WHOLE: &'static str = "argument";

What the whole is called: product or sum.
Source§

impl<This> CliProgramExt<This> for This

Source§

fn compile_cli<Program>( &self, program: Program, ) -> <Program as CliProgramAlg<This>>::Commands
where Program: CliProgramAlg<This>,

Compiles a named CLI program with this interpreter.

Source§

impl<Source> CliStatedFor<ContextArg> for Source

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<This> ShapeProgramExt<This> for This

Source§

fn compile_shape<Program>( &self, program: Program, ) -> <Program as ShapeProgramAlg<This>>::Ty
where Program: ShapeProgramAlg<This>,

Folds a declaration with this interpretation.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.