aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/plugin/pre_command_run_event.rs
blob: 21eb232360199bea7eaa230b4e5e70c9536ca3d9 (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
//! ref: composer/src/Composer/Plugin/PreCommandRunEvent.php

// TODO(plugin): this event is part of the plugin API and is dispatched before a command runs
use crate::event_dispatcher::Event;
use shirabe_external_packages::symfony::component::console::input::InputInterface;

#[derive(Debug)]
pub struct PreCommandRunEvent {
    inner: Event,
    input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
    command: String,
}

impl PreCommandRunEvent {
    pub fn new(
        name: String,
        input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
        command: String,
    ) -> Self {
        let inner = Event::new(name, vec![], indexmap::IndexMap::new());
        Self {
            inner,
            input,
            command,
        }
    }

    pub fn get_input(&self) -> std::rc::Rc<std::cell::RefCell<dyn InputInterface>> {
        self.input.clone()
    }

    pub fn get_name(&self) -> &str {
        self.inner.get_name()
    }

    pub fn get_command(&self) -> &str {
        &self.command
    }
}