aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/plugin/command_event.rs
blob: 715f29a7ec6710232d551ee332399e498d26c846 (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
//! ref: composer/src/Composer/Plugin/CommandEvent.php

use crate::event_dispatcher::event::Event;
use indexmap::IndexMap;
use shirabe_external_packages::symfony::console::input::input_interface::InputInterface;
use shirabe_external_packages::symfony::console::output::output_interface::OutputInterface;
use shirabe_php_shim::PhpMixed;

#[derive(Debug)]
pub struct CommandEvent {
    inner: Event,
    command_name: String,
}

impl CommandEvent {
    // TODO(phase-b): input/output dropped because storing &dyn references in an event would
    // require lifetime parameters; restore once Plugin API needs them.
    pub fn new(
        name: String,
        command_name: String,
        _input: &dyn InputInterface,
        _output: &dyn OutputInterface,
        args: Vec<String>,
        flags: IndexMap<String, PhpMixed>,
    ) -> Self {
        let inner = Event::new(name, args, flags);
        Self {
            inner,
            command_name,
        }
    }

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

    pub fn get_command_name(&self) -> &str {
        &self.command_name
    }
}