diff options
Diffstat (limited to 'crates/shirabe/src/plugin')
| -rw-r--r-- | crates/shirabe/src/plugin/command_event.rs | 24 | ||||
| -rw-r--r-- | crates/shirabe/src/plugin/pre_command_run_event.rs | 18 |
2 files changed, 32 insertions, 10 deletions
diff --git a/crates/shirabe/src/plugin/command_event.rs b/crates/shirabe/src/plugin/command_event.rs index bcfe256..838260c 100644 --- a/crates/shirabe/src/plugin/command_event.rs +++ b/crates/shirabe/src/plugin/command_event.rs @@ -10,25 +10,25 @@ use shirabe_php_shim::PhpMixed; pub struct CommandEvent { inner: Event, command_name: String, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, } 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: &str, command_name: &str, - _input: &dyn InputInterface, - _output: &dyn OutputInterface, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, ) -> Self { - Self::new6(name, command_name, _input, _output, vec![], IndexMap::new()) + Self::new6(name, command_name, input, output, vec![], IndexMap::new()) } pub fn new6( name: &str, command_name: &str, - _input: &dyn InputInterface, - _output: &dyn OutputInterface, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, + output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>, args: Vec<String>, flags: IndexMap<String, PhpMixed>, ) -> Self { @@ -36,9 +36,19 @@ impl CommandEvent { Self { inner, command_name: command_name.to_string(), + input, + output, } } + pub fn get_input(&self) -> std::rc::Rc<std::cell::RefCell<dyn InputInterface>> { + self.input.clone() + } + + pub fn get_output(&self) -> std::rc::Rc<std::cell::RefCell<dyn OutputInterface>> { + self.output.clone() + } + pub fn get_name(&self) -> &str { self.inner.get_name() } diff --git a/crates/shirabe/src/plugin/pre_command_run_event.rs b/crates/shirabe/src/plugin/pre_command_run_event.rs index 2af2626..21eb232 100644 --- a/crates/shirabe/src/plugin/pre_command_run_event.rs +++ b/crates/shirabe/src/plugin/pre_command_run_event.rs @@ -7,14 +7,26 @@ use shirabe_external_packages::symfony::component::console::input::InputInterfac #[derive(Debug)] pub struct PreCommandRunEvent { inner: Event, + input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>, command: String, } impl PreCommandRunEvent { - // TODO(phase-b): input dropped because storing a &dyn reference would need lifetime params. - pub fn new(name: String, _input: &dyn InputInterface, command: String) -> Self { + 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, command } + 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 { |
