aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-20 05:55:46 +0900
committernsfisis <nsfisis@gmail.com>2026-07-20 05:55:46 +0900
commit7f14217abbba2f89ae5845d63c8f97b606354f45 (patch)
treea000f7297f8aff509b74ce25ff871b334bcfc191 /crates/shirabe/src/command
parentb151ceaa798a7d2e9b55ffbc4e4b10ea8f0a59a8 (diff)
downloadphp-shirabe-7f14217abbba2f89ae5845d63c8f97b606354f45.tar.gz
php-shirabe-7f14217abbba2f89ae5845d63c8f97b606354f45.tar.zst
php-shirabe-7f14217abbba2f89ae5845d63c8f97b606354f45.zip
fix(io): widen IOInterface::select choices to PhpMixed for assoc arrays
PHP's IOInterface::select accepts an associative choices array whose keys are the selectable values, but the port narrowed it to Vec<String>, making key-based selection unrepresentable. Accept PhpMixed (List or Array) like PHP's array $choices; ConsoleIO already branched on both shapes internally. Also mirror PHP in the single-select array_search fallback for numeric-keyed arrays. All call sites keep their previous list-based behavior. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command')
-rw-r--r--crates/shirabe/src/command/exec_command.rs7
-rw-r--r--crates/shirabe/src/command/package_discovery_trait.rs4
-rw-r--r--crates/shirabe/src/command/run_script_command.rs7
-rw-r--r--crates/shirabe/src/command/update_command.rs10
4 files changed, 21 insertions, 7 deletions
diff --git a/crates/shirabe/src/command/exec_command.rs b/crates/shirabe/src/command/exec_command.rs
index 3eaee5a9..057c9eb2 100644
--- a/crates/shirabe/src/command/exec_command.rs
+++ b/crates/shirabe/src/command/exec_command.rs
@@ -118,7 +118,12 @@ impl Command for ExecCommand {
let io = self.get_io();
let binary = io.select(
"Binary to run: ".to_string(),
- binaries.clone(),
+ PhpMixed::List(
+ binaries
+ .iter()
+ .map(|b| PhpMixed::String(b.clone()))
+ .collect(),
+ ),
PhpMixed::String(String::new()),
PhpMixed::Int(1),
"Invalid binary name \"%s\"".to_string(),
diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs
index 830f1996..2ab1d9d5 100644
--- a/crates/shirabe/src/command/package_discovery_trait.rs
+++ b/crates/shirabe/src/command/package_discovery_trait.rs
@@ -689,7 +689,9 @@ pub trait PackageDiscoveryTrait: BaseCommand {
"<error>Could not find package {}.</error>\nPick one of these or leave empty to abort:",
name,
),
- similar.to_vec(),
+ PhpMixed::List(
+ similar.iter().map(|s| PhpMixed::String(s.clone())).collect(),
+ ),
PhpMixed::Bool(false),
PhpMixed::Int(1),
"No package named \"%s\" is installed.".to_string(),
diff --git a/crates/shirabe/src/command/run_script_command.rs b/crates/shirabe/src/command/run_script_command.rs
index c256eea2..26e73d6d 100644
--- a/crates/shirabe/src/command/run_script_command.rs
+++ b/crates/shirabe/src/command/run_script_command.rs
@@ -209,7 +209,12 @@ impl Command for RunScriptCommand {
let io = self.get_io();
let script = io.select(
"Script to run: ".to_string(),
- options.keys().cloned().collect(),
+ PhpMixed::List(
+ options
+ .keys()
+ .map(|k| PhpMixed::String(k.clone()))
+ .collect(),
+ ),
PhpMixed::String(String::new()),
PhpMixed::Int(1),
"Invalid script name \"%s\"".to_string(),
diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs
index b47c51d0..a20d288f 100644
--- a/crates/shirabe/src/command/update_command.rs
+++ b/crates/shirabe/src/command/update_command.rs
@@ -705,10 +705,12 @@ impl UpdateCommand {
let select_result = io.select(
"Select packages: (Select more than one value separated by comma) ".to_string(),
- autocompleter_values
- .keys()
- .cloned()
- .collect::<Vec<String>>(),
+ PhpMixed::List(
+ autocompleter_values
+ .keys()
+ .map(|k| PhpMixed::String(k.clone()))
+ .collect(),
+ ),
PhpMixed::Bool(false),
PhpMixed::Int(1),
"No package named \"%s\" is installed.".to_string(),