Struct cucumber::cli::Compose

source ·
pub struct Compose<L: Args, R: Args> {
    pub left: L,
    pub right: R,
}
Expand description

Composes two clap::Args derivers together.

Example

This struct is especially useful, when implementing custom Writer wrapping another one:

struct CustomWriter<Wr>(Wr);

#[derive(cli::Args)] // re-export of `clap::Args`
struct Cli {
    #[arg(long)]
    custom_option: Option<String>,
}

#[async_trait(?Send)]
impl<W, Wr> Writer<W> for CustomWriter<Wr>
where
    W: World,
    Wr: Writer<W>,
{
    type Cli = cli::Compose<Cli, Wr::Cli>;

    async fn handle_event(
        &mut self,
        ev: parser::Result<Event<event::Cucumber<W>>>,
        cli: &Self::Cli,
    ) {
        // Some custom logic including `cli.left.custom_option`.
        // ...
        self.0.handle_event(ev, &cli.right).await;
    }
}

// Useful blanket impls:

impl cli::Colored for Cli {}

#[async_trait(?Send)]
impl<'val, W, Wr, Val> writer::Arbitrary<'val, W, Val> for CustomWriter<Wr>
where
    Wr: writer::Arbitrary<'val, W, Val>,
    Val: 'val,
    Self: Writer<W>,
{
    async fn write(&mut self, val: Val)
    where
        'val: 'async_trait,
    {
        self.0.write(val).await;
    }
}

impl<W, Wr> writer::Stats<W> for CustomWriter<Wr>
where
    Wr: writer::Stats<W>,
    Self: Writer<W>,
{
    fn passed_steps(&self) -> usize {
        self.0.failed_steps()
    }

    fn skipped_steps(&self) -> usize {
        self.0.failed_steps()
    }

    fn failed_steps(&self) -> usize {
        self.0.failed_steps()
    }

    fn retried_steps(&self) -> usize {
        self.0.retried_steps()
    }

    fn parsing_errors(&self) -> usize {
        self.0.parsing_errors()
    }

    fn hook_errors(&self) -> usize {
        self.0.hook_errors()
    }
}

impl<Wr: writer::Normalized> writer::Normalized for CustomWriter<Wr> {}

impl<Wr: writer::NonTransforming> writer::NonTransforming
    for CustomWriter<Wr>
{}

Fields§

§left: L

Left clap::Args deriver.

§right: R

Right clap::Args deriver.

Implementations§

Unpacks this Compose into the underlying CLIs.

Trait Implementations§

Report the ArgGroup::id for this set of arguments
Append to Command so it can instantiate Self. Read more
Append to Command so it can update self. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Returns Coloring indicating whether a Writer using CLI options supports colored output or not.
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Instantiate Self from ArgMatches, parsing the arguments as needed. Read more
Assign values from ArgMatches to self.
Assign values from ArgMatches to self.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Asserts this Writer being Normalized. Read more
Wraps this Writer into a Normalized version. Read more
Wraps this Writer to print a summary at the end of an output. Read more
Wraps this Writer to fail on Skipped Steps if their Scenario isn’t marked with @allow.skipped tag. Read more
Wraps this Writer to fail on Skipped Steps if the given with predicate returns true. Read more
Wraps this Writer to re-output Skipped Steps at the end of an output.
Wraps this Writer to re-output Failed Steps or Parser errors at the end of an output.
Wraps this Writer to re-output filtered events at the end of an output.
Attaches the provided other Writer to the current one for passing events to both of them simultaneously.
Wraps this Writer into a discard::Arbitrary one, providing a no-op ArbitraryWriter implementation. Read more
Wraps this Writer into a discard::Stats one, providing a no-op StatsWriter implementation returning only 0. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.