aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command/run_script_command.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-06 18:04:45 +0900
committernsfisis <nsfisis@gmail.com>2026-06-06 18:04:45 +0900
commitd5b313f388d424e60ae33ae58c1a65a65b24b8f1 (patch)
tree849ada9b7319b8eb85aab28e02f614023fea2105 /crates/shirabe/src/command/run_script_command.rs
parent71b432db3f115d17be498f36cd3efd40b4650a0b (diff)
downloadphp-shirabe-d5b313f388d424e60ae33ae58c1a65a65b24b8f1.tar.gz
php-shirabe-d5b313f388d424e60ae33ae58c1a65a65b24b8f1.tar.zst
php-shirabe-d5b313f388d424e60ae33ae58c1a65a65b24b8f1.zip
refactor(command): share Input/OutputInterface via Rc<RefCell>
Convert InputInterface and OutputInterface parameters from &dyn/&mut dyn references to Rc<RefCell<dyn ...>> shared ownership across the command, console, and IO layers, matching the Phase C shared-ownership approach already used for IOInterface. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command/run_script_command.rs')
-rw-r--r--crates/shirabe/src/command/run_script_command.rs34
1 files changed, 21 insertions, 13 deletions
diff --git a/crates/shirabe/src/command/run_script_command.rs b/crates/shirabe/src/command/run_script_command.rs
index 9118463..cf8b8f1 100644
--- a/crates/shirabe/src/command/run_script_command.rs
+++ b/crates/shirabe/src/command/run_script_command.rs
@@ -115,16 +115,16 @@ impl RunScriptCommand {
pub fn interact(
&mut self,
- input: &mut dyn InputInterface,
- _output: &dyn OutputInterface,
+ input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
+ _output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
) -> Result<()> {
let scripts = self.get_scripts()?;
if scripts.is_empty() {
return Ok(());
}
- if input.get_argument("script").as_string().is_some()
- || input.get_option("list").as_bool().unwrap_or(false)
+ if input.borrow().get_argument("script").as_string().is_some()
+ || input.borrow().get_option("list").as_bool().unwrap_or(false)
{
return Ok(());
}
@@ -145,7 +145,7 @@ impl RunScriptCommand {
);
if let Some(selected) = script.as_string() {
- // TODO(phase-b): input is &dyn InputInterface but set_argument needs &mut.
+ // TODO(phase-b): input is std::rc::Rc<std::cell::RefCell<dyn InputInterface>> but set_argument needs &mut.
let _ = selected;
}
@@ -154,14 +154,14 @@ impl RunScriptCommand {
pub fn execute(
&mut self,
- input: &dyn InputInterface,
- output: &dyn OutputInterface,
+ input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
+ output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
) -> Result<i64> {
- if input.get_option("list").as_bool().unwrap_or(false) {
+ if input.borrow().get_option("list").as_bool().unwrap_or(false) {
return self.list_scripts(output);
}
- let script = match input.get_argument("script").as_string() {
+ let script = match input.borrow().get_argument("script").as_string() {
None => {
return Err(RuntimeException {
message: "Missing required argument \"script\"".to_string(),
@@ -187,8 +187,12 @@ impl RunScriptCommand {
let dispatcher = crate::command::composer_full(&composer)
.get_event_dispatcher()
.clone();
- let dev_mode = input.get_option("dev").as_bool().unwrap_or(false)
- || !input.get_option("no-dev").as_bool().unwrap_or(false);
+ let dev_mode = input.borrow().get_option("dev").as_bool().unwrap_or(false)
+ || !input
+ .borrow()
+ .get_option("no-dev")
+ .as_bool()
+ .unwrap_or(false);
// TODO(phase-b): ScriptEvent::new takes Composer/IOInterface by value; placeholder construction.
let _ = (script.clone(), &composer, dev_mode);
let has_listeners = false;
@@ -201,6 +205,7 @@ impl RunScriptCommand {
}
let args: Vec<String> = input
+ .borrow()
.get_argument("args")
.as_list()
.map(|l| {
@@ -210,7 +215,7 @@ impl RunScriptCommand {
})
.unwrap_or_default();
- if let Some(timeout_val) = input.get_option("timeout").as_string() {
+ if let Some(timeout_val) = input.borrow().get_option("timeout").as_string() {
let timeout_str = timeout_val.to_string();
if !timeout_str.chars().all(|c| c.is_ascii_digit()) {
return Err(RuntimeException {
@@ -232,7 +237,10 @@ impl RunScriptCommand {
.dispatch_script(&script, dev_mode, args, IndexMap::new())?)
}
- fn list_scripts(&mut self, output: &dyn OutputInterface) -> Result<i64> {
+ fn list_scripts(
+ &mut self,
+ output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
+ ) -> Result<i64> {
let scripts = self.get_scripts()?;
if scripts.is_empty() {
return Ok(0);