aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src/symfony/console/event/console_event.rs
blob: 96b9a31b54fcee99b5d744d6d4bf41296944fd76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::symfony::console::command::command::Command;
use crate::symfony::console::input::input_interface::InputInterface;
use crate::symfony::console::output::output_interface::OutputInterface;
use crate::symfony::contracts::event_dispatcher::event::Event;

/// Allows to inspect input and output of a command.
#[derive(Debug)]
pub struct ConsoleEvent {
    inner: Event,
    pub(crate) command: Option<Box<dyn Command>>,
    input: Box<dyn InputInterface>,
    output: Box<dyn OutputInterface>,
}

impl ConsoleEvent {
    pub fn new(
        command: Option<Box<dyn Command>>,
        input: Box<dyn InputInterface>,
        output: Box<dyn OutputInterface>,
    ) -> Self {
        Self {
            inner: Event,
            command,
            input,
            output,
        }
    }

    pub fn get_command(&self) -> Option<&dyn Command> {
        self.command.as_deref()
    }

    pub fn get_input(&self) -> &dyn InputInterface {
        self.input.as_ref()
    }

    pub fn get_output(&self) -> &dyn OutputInterface {
        self.output.as_ref()
    }
}