aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/src/command')
-rw-r--r--crates/shirabe/src/command/archive_command.rs2
-rw-r--r--crates/shirabe/src/command/audit_command.rs7
-rw-r--r--crates/shirabe/src/command/base_command.rs40
-rw-r--r--crates/shirabe/src/command/bump_command.rs12
-rw-r--r--crates/shirabe/src/command/check_platform_reqs_command.rs5
-rw-r--r--crates/shirabe/src/command/config_command.rs22
-rw-r--r--crates/shirabe/src/command/create_project_command.rs14
-rw-r--r--crates/shirabe/src/command/depends_command.rs4
-rw-r--r--crates/shirabe/src/command/dump_autoload_command.rs6
-rw-r--r--crates/shirabe/src/command/exec_command.rs18
-rw-r--r--crates/shirabe/src/command/fund_command.rs5
-rw-r--r--crates/shirabe/src/command/global_command.rs2
-rw-r--r--crates/shirabe/src/command/home_command.rs12
-rw-r--r--crates/shirabe/src/command/init_command.rs70
-rw-r--r--crates/shirabe/src/command/install_command.rs20
-rw-r--r--crates/shirabe/src/command/licenses_command.rs5
-rw-r--r--crates/shirabe/src/command/outdated_command.rs73
-rw-r--r--crates/shirabe/src/command/prohibits_command.rs4
-rw-r--r--crates/shirabe/src/command/reinstall_command.rs14
-rw-r--r--crates/shirabe/src/command/remove_command.rs25
-rw-r--r--crates/shirabe/src/command/repository_command.rs11
-rw-r--r--crates/shirabe/src/command/require_command.rs37
-rw-r--r--crates/shirabe/src/command/run_script_command.rs15
-rw-r--r--crates/shirabe/src/command/script_alias_command.rs8
-rw-r--r--crates/shirabe/src/command/search_command.rs19
-rw-r--r--crates/shirabe/src/command/self_update_command.rs4
-rw-r--r--crates/shirabe/src/command/show_command.rs17
-rw-r--r--crates/shirabe/src/command/status_command.rs2
-rw-r--r--crates/shirabe/src/command/suggests_command.rs14
-rw-r--r--crates/shirabe/src/command/update_command.rs35
-rw-r--r--crates/shirabe/src/command/validate_command.rs2
31 files changed, 249 insertions, 275 deletions
diff --git a/crates/shirabe/src/command/archive_command.rs b/crates/shirabe/src/command/archive_command.rs
index e10601ac..a50b9602 100644
--- a/crates/shirabe/src/command/archive_command.rs
+++ b/crates/shirabe/src/command/archive_command.rs
@@ -310,7 +310,7 @@ impl Command for ArchiveCommand {
self.set_definition(&[
InputArgument::new5("package", Some(InputArgument::OPTIONAL), "The package to archive instead of the current project", None, self.suggest_available_package(99)).unwrap().into(),
InputArgument::new("version", Some(InputArgument::OPTIONAL), "A version constraint to find the package to archive", None).unwrap().into(),
- InputOption::new6("format", Some(shirabe_php_shim::PhpMixed::String("f".to_string())), Some(InputOption::VALUE_REQUIRED), "Format of the resulting archive: tar, tar.gz, tar.bz2 or zip (default tar)", None, SuggestedValues::List(Self::FORMATS.iter().map(|s| s.to_string()).collect())).unwrap().into(),
+ InputOption::new6("format", Some("f"), Some(InputOption::VALUE_REQUIRED), "Format of the resulting archive: tar, tar.gz, tar.bz2 or zip (default tar)", None, SuggestedValues::List(Self::FORMATS.iter().map(|s| s.to_string()).collect())).unwrap().into(),
InputOption::new("dir", None, Some(InputOption::VALUE_REQUIRED), "Write the archive to this directory", None).unwrap().into(),
InputOption::new("file", None, Some(InputOption::VALUE_REQUIRED), "Write the archive with the given file name. Note that the format will be appended.", None).unwrap().into(),
InputOption::new("ignore-filters", None, Some(InputOption::VALUE_NONE), "Ignore filters when saving package", None).unwrap().into(),
diff --git a/crates/shirabe/src/command/audit_command.rs b/crates/shirabe/src/command/audit_command.rs
index d067e074..238451e0 100644
--- a/crates/shirabe/src/command/audit_command.rs
+++ b/crates/shirabe/src/command/audit_command.rs
@@ -19,6 +19,7 @@ use shirabe_php_shim::{
};
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
#[derive(Debug)]
@@ -113,10 +114,10 @@ impl Command for AuditCommand {
.into(),
InputOption::new6(
"format",
- Some(PhpMixed::String("f".to_string())),
+ Some("f"),
Some(InputOption::VALUE_REQUIRED),
"Output format. Must be \"table\", \"plain\", \"json\", or \"summary\".",
- Some(PhpMixed::String(Auditor::FORMAT_TABLE.to_string())),
+ Some(InputValue::String(Auditor::FORMAT_TABLE.to_string())),
SuggestedValues::List(Auditor::FORMATS.iter().map(|s| s.to_string()).collect()),
)
.unwrap()
@@ -145,7 +146,7 @@ impl Command for AuditCommand {
None,
Some(InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED),
"Ignore advisories of a certain severity level.",
- Some(PhpMixed::Array(indexmap::IndexMap::new())),
+ Some(InputValue::Array(vec![])),
SuggestedValues::List(vec![
"low".to_string(),
"medium".to_string(),
diff --git a/crates/shirabe/src/command/base_command.rs b/crates/shirabe/src/command/base_command.rs
index 8ec9f350..d1d9ecf2 100644
--- a/crates/shirabe/src/command/base_command.rs
+++ b/crates/shirabe/src/command/base_command.rs
@@ -26,7 +26,9 @@ use shirabe_symfony_console::Terminal;
use shirabe_symfony_console::command::{Command, CommandData, SetDefinitionArg};
use shirabe_symfony_console::helper::Table;
use shirabe_symfony_console::helper::TableSeparator;
+use shirabe_symfony_console::input::ArgumentName;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
pub const SUCCESS: i64 = 0;
@@ -122,7 +124,7 @@ pub trait BaseCommand: Command {
name: &str,
mode: Option<i64>,
description: &str,
- default: PhpMixed,
+ default: InputValue,
) -> &Self
where
Self: Sized,
@@ -139,14 +141,11 @@ pub trait BaseCommand: Command {
shortcut: Option<&str>,
mode: Option<i64>,
description: &str,
- default: PhpMixed,
+ default: InputValue,
) -> &Self
where
Self: Sized,
{
- let shortcut = shortcut
- .map(|s| PhpMixed::from(s.to_string()))
- .unwrap_or(PhpMixed::Null);
self.command_data()
.add_option(name, shortcut, mode, description, default)
.expect("command option definitions in configure() are statically valid");
@@ -400,11 +399,11 @@ impl BaseCommand for BaseCommandData {
let disable_plugins = disable_plugins
|| input
.borrow()
- .has_parameter_option(PhpMixed::from(vec!["--no-plugins"]), false);
+ .has_parameter_option(&["--no-plugins"], false);
let disable_scripts = disable_scripts.unwrap_or(false)
|| input
.borrow()
- .has_parameter_option(PhpMixed::from(vec!["--no-scripts"]), false);
+ .has_parameter_option(&["--no-scripts"], false);
let (disable_plugins, disable_scripts) =
apply_application_defaults(self.get_application(), disable_plugins, disable_scripts);
@@ -478,12 +477,12 @@ impl BaseCommand for BaseCommandData {
"dist" => {
input
.borrow_mut()
- .set_option("prefer-dist", PhpMixed::Bool(true))?;
+ .set_option("prefer-dist", InputValue::Bool(true))?;
}
"source" => {
input
.borrow_mut()
- .set_option("prefer-source", PhpMixed::Bool(true))?;
+ .set_option("prefer-source", InputValue::Bool(true))?;
}
"auto" => {
prefer_dist = false;
@@ -771,7 +770,7 @@ pub fn base_command_complete(
} else if CompletionInput::TYPE_ARGUMENT_VALUE == input.get_completion_type()
&& cmd
.get_definition()
- .has_argument(&PhpMixed::String(name.clone()))
+ .has_argument(&ArgumentName::Name(name.clone()))
{
let argument = cmd
.base_command_data()
@@ -799,10 +798,10 @@ pub fn base_command_initialize(
// initialize a plugin-enabled Composer instance, either local or global
let disable_plugins = input
.borrow()
- .has_parameter_option(PhpMixed::from(vec!["--no-plugins"]), false);
+ .has_parameter_option(&["--no-plugins"], false);
let disable_scripts = input
.borrow()
- .has_parameter_option(PhpMixed::from(vec!["--no-scripts"]), false);
+ .has_parameter_option(&["--no-scripts"], false);
let (mut disable_plugins, mut disable_scripts) =
apply_application_defaults(cmd.get_application(), disable_plugins, disable_scripts);
@@ -839,14 +838,12 @@ pub fn base_command_initialize(
)?;
}
- if input
- .borrow()
- .has_parameter_option(PhpMixed::from(vec!["--no-ansi"]), false)
+ if input.borrow().has_parameter_option(&["--no-ansi"], false)
&& input.borrow().has_option("no-progress")
{
input
.borrow_mut()
- .set_option("no-progress", PhpMixed::Bool(true));
+ .set_option("no-progress", InputValue::Bool(true));
}
let env_options: IndexMap<&str, Vec<&str>> = [
@@ -879,7 +876,7 @@ pub fn base_command_initialize(
{
input
.borrow_mut()
- .set_option(option_name, PhpMixed::Bool(true));
+ .set_option(option_name, InputValue::Bool(true));
}
}
}
@@ -895,7 +892,7 @@ pub fn base_command_initialize(
{
input
.borrow_mut()
- .set_option("ignore-platform-reqs", PhpMixed::Bool(true));
+ .set_option("ignore-platform-reqs", InputValue::Bool(true));
io.write_error("<warning>COMPOSER_IGNORE_PLATFORM_REQS is set. You may experience unexpected errors.</warning>");
}
@@ -917,12 +914,7 @@ pub fn base_command_initialize(
{
input.borrow_mut().set_option(
"ignore-platform-req",
- PhpMixed::List(
- explode(",", &ignore_str)
- .into_iter()
- .map(PhpMixed::String)
- .collect(),
- ),
+ InputValue::Array(explode(",", &ignore_str)),
);
io.write_error(&format!(
diff --git a/crates/shirabe/src/command/bump_command.rs b/crates/shirabe/src/command/bump_command.rs
index 3b680a29..8f95366f 100644
--- a/crates/shirabe/src/command/bump_command.rs
+++ b/crates/shirabe/src/command/bump_command.rs
@@ -349,7 +349,7 @@ impl Command for BumpCommand {
.into(),
InputOption::new(
"dev-only",
- Some(PhpMixed::String("D".to_string())),
+ Some("D"),
Some(InputOption::VALUE_NONE),
"Only bump requirements in \"require-dev\".",
None,
@@ -358,7 +358,7 @@ impl Command for BumpCommand {
.into(),
InputOption::new(
"no-dev-only",
- Some(PhpMixed::String("R".to_string())),
+ Some("R"),
Some(InputOption::VALUE_NONE),
"Only bump requirements in \"require\".",
None,
@@ -397,12 +397,8 @@ impl Command for BumpCommand {
let packages_filter: Vec<String> = input
.borrow()
.get_argument("packages")?
- .as_list()
- .map(|l| {
- l.iter()
- .filter_map(|v| v.as_string().map(|s| s.to_string()))
- .collect()
- })
+ .as_array()
+ .map(<[String]>::to_vec)
.unwrap_or_default();
let dev_only = input
diff --git a/crates/shirabe/src/command/check_platform_reqs_command.rs b/crates/shirabe/src/command/check_platform_reqs_command.rs
index d1cbf33c..21e71fee 100644
--- a/crates/shirabe/src/command/check_platform_reqs_command.rs
+++ b/crates/shirabe/src/command/check_platform_reqs_command.rs
@@ -17,6 +17,7 @@ use shirabe_semver::constraint::AnyConstraint;
use shirabe_semver::constraint::SimpleConstraint;
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
struct CheckResult {
@@ -165,10 +166,10 @@ impl Command for CheckPlatformReqsCommand {
.into(),
InputOption::new6(
"format",
- Some(shirabe_php_shim::PhpMixed::String("f".to_string())),
+ Some("f"),
Some(InputOption::VALUE_REQUIRED),
"Format of the output: text or json",
- Some(shirabe_php_shim::PhpMixed::String("text".to_string())),
+ Some(InputValue::String("text".to_string())),
SuggestedValues::List(vec!["json".to_string(), "text".to_string()]),
)
.unwrap()
diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs
index 0788d694..90f2d7c0 100644
--- a/crates/shirabe/src/command/config_command.rs
+++ b/crates/shirabe/src/command/config_command.rs
@@ -443,15 +443,15 @@ impl Command for ConfigCommand {
self.set_name("config")?;
self.set_description("Sets config options");
self.set_definition(&[
- InputOption::new("global", Some(PhpMixed::String("g".to_string())), Some(InputOption::VALUE_NONE), "Apply command to the global config file", None).unwrap().into(),
- InputOption::new("editor", Some(PhpMixed::String("e".to_string())), Some(InputOption::VALUE_NONE), "Open editor", None).unwrap().into(),
- InputOption::new("auth", Some(PhpMixed::String("a".to_string())), Some(InputOption::VALUE_NONE), "Affect auth config file (only used for --editor)", None).unwrap().into(),
+ InputOption::new("global", Some("g"), Some(InputOption::VALUE_NONE), "Apply command to the global config file", None).unwrap().into(),
+ InputOption::new("editor", Some("e"), Some(InputOption::VALUE_NONE), "Open editor", None).unwrap().into(),
+ InputOption::new("auth", Some("a"), Some(InputOption::VALUE_NONE), "Affect auth config file (only used for --editor)", None).unwrap().into(),
InputOption::new("unset", None, Some(InputOption::VALUE_NONE), "Unset the given setting-key", None).unwrap().into(),
- InputOption::new("list", Some(PhpMixed::String("l".to_string())), Some(InputOption::VALUE_NONE), "List configuration settings", None).unwrap().into(),
- InputOption::new("file", Some(PhpMixed::String("f".to_string())), Some(InputOption::VALUE_REQUIRED), "If you want to choose a different composer.json or config.json", None).unwrap().into(),
+ InputOption::new("list", Some("l"), Some(InputOption::VALUE_NONE), "List configuration settings", None).unwrap().into(),
+ InputOption::new("file", Some("f"), Some(InputOption::VALUE_REQUIRED), "If you want to choose a different composer.json or config.json", None).unwrap().into(),
InputOption::new("absolute", None, Some(InputOption::VALUE_NONE), "Returns absolute paths when fetching *-dir config values instead of relative", None).unwrap().into(),
- InputOption::new("json", Some(PhpMixed::String("j".to_string())), Some(InputOption::VALUE_NONE), "JSON decode the setting value, to be used with extra.* keys", None).unwrap().into(),
- InputOption::new("merge", Some(PhpMixed::String("m".to_string())), Some(InputOption::VALUE_NONE), "Merge the setting value with the current value, to be used with extra.* or audit.ignore[-abandoned] keys in combination with --json", None).unwrap().into(),
+ InputOption::new("json", Some("j"), Some(InputOption::VALUE_NONE), "JSON decode the setting value, to be used with extra.* keys", None).unwrap().into(),
+ InputOption::new("merge", Some("m"), Some(InputOption::VALUE_NONE), "Merge the setting value with the current value, to be used with extra.* or audit.ignore[-abandoned] keys in combination with --json", None).unwrap().into(),
InputOption::new("append", None, Some(InputOption::VALUE_NONE), "When adding a repository, append it (lowest priority) to the existing ones instead of prepending it (highest priority)", None).unwrap().into(),
InputOption::new("source", None, Some(InputOption::VALUE_NONE), "Display where the config value is loaded from", None).unwrap().into(),
InputArgument::new5("setting-key", None, "Setting key", None, self.suggest_setting_keys()).unwrap().into(),
@@ -664,12 +664,8 @@ impl Command for ConfigCommand {
// If the user enters in a config variable, parse it and save to file
let setting_values_raw = input.borrow().get_argument("setting-value")?;
let setting_values: Vec<String> = setting_values_raw
- .as_list()
- .map(|l| {
- l.iter()
- .filter_map(|v| v.as_string().map(|s| s.to_string()))
- .collect()
- })
+ .as_array()
+ .map(<[String]>::to_vec)
.unwrap_or_default();
if !setting_values.is_empty() && input.borrow().get_option("unset")?.as_bool() == Some(true)
{
diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs
index eb23ffff..e2161aa3 100644
--- a/crates/shirabe/src/command/create_project_command.rs
+++ b/crates/shirabe/src/command/create_project_command.rs
@@ -45,6 +45,7 @@ use shirabe_php_shim::{
};
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
use shirabe_symfony_finder::Finder;
use std::path::PathBuf;
@@ -834,7 +835,7 @@ impl Command for CreateProjectCommand {
InputArgument::new5("package", Some(InputArgument::OPTIONAL), "Package name to be installed", None, self.suggest_available_package(99)).unwrap().into(),
InputArgument::new("directory", Some(InputArgument::OPTIONAL), "Directory where the files should be created", None).unwrap().into(),
InputArgument::new("version", Some(InputArgument::OPTIONAL), "Version, will default to latest", None).unwrap().into(),
- InputOption::new("stability", Some(PhpMixed::String("s".to_string())), Some(InputOption::VALUE_REQUIRED), "Minimum-stability allowed (unless a version is specified).", None).unwrap().into(),
+ InputOption::new("stability", Some("s"), Some(InputOption::VALUE_REQUIRED), "Minimum-stability allowed (unless a version is specified).", None).unwrap().into(),
InputOption::new("prefer-source", None, Some(InputOption::VALUE_NONE), "Forces installation from package sources when possible, including VCS information.", None).unwrap().into(),
InputOption::new("prefer-dist", None, Some(InputOption::VALUE_NONE), "Forces installation from package dist (default behavior).", None).unwrap().into(),
InputOption::new6("prefer-install", None, Some(InputOption::VALUE_REQUIRED), "Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).", None, self.suggest_prefer_install()).unwrap().into(),
@@ -851,7 +852,7 @@ impl Command for CreateProjectCommand {
InputOption::new("remove-vcs", None, Some(InputOption::VALUE_NONE), "Whether to force deletion of the vcs folder without prompting.", None).unwrap().into(),
InputOption::new("no-install", None, Some(InputOption::VALUE_NONE), "Whether to skip installation of the package dependencies.", None).unwrap().into(),
InputOption::new("no-audit", None, Some(InputOption::VALUE_NONE), "Whether to skip auditing of the installed package dependencies (can also be set via the COMPOSER_NO_AUDIT=1 env var).", None).unwrap().into(),
- InputOption::new6("audit-format", None, Some(InputOption::VALUE_REQUIRED), "Audit output format. Must be \"table\", \"plain\", \"json\" or \"summary\".", Some(PhpMixed::String(Auditor::FORMAT_SUMMARY.to_string())), SuggestedValues::List(Auditor::FORMATS.iter().map(|s| s.to_string()).collect())).unwrap().into(),
+ InputOption::new6("audit-format", None, Some(InputOption::VALUE_REQUIRED), "Audit output format. Must be \"table\", \"plain\", \"json\" or \"summary\".", Some(InputValue::String(Auditor::FORMAT_SUMMARY.to_string())), SuggestedValues::List(Auditor::FORMATS.iter().map(|s| s.to_string()).collect())).unwrap().into(),
InputOption::new("no-security-blocking", None, Some(InputOption::VALUE_NONE), "Allows installing packages with security advisories or that are abandoned (can also be set via the COMPOSER_NO_SECURITY_BLOCKING=1 env var).", None).unwrap().into(),
InputOption::new("ignore-platform-req", None, Some(InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY), "Ignore a specific platform requirement (php & ext- packages).", None).unwrap().into(),
InputOption::new("ignore-platform-reqs", None, Some(InputOption::VALUE_NONE), "Ignore all platform requirements (php & ext- packages).", None).unwrap().into(),
@@ -900,7 +901,7 @@ impl Command for CreateProjectCommand {
io.write_error("<warning>You are using the deprecated option \"no-custom-installers\". Use \"no-plugins\" instead.</warning>");
input
.borrow_mut()
- .set_option("no-plugins", PhpMixed::Bool(true));
+ .set_option("no-plugins", InputValue::Bool(true));
}
if input.borrow().is_interactive()
@@ -919,9 +920,10 @@ impl Command for CreateProjectCommand {
"New project directory [<comment>{}</comment>]: ",
array_pop(&mut parts).unwrap_or_default()
);
- input
- .borrow_mut()
- .set_argument("directory", io.ask(prompt, PhpMixed::Null)?);
+ input.borrow_mut().set_argument(
+ "directory",
+ InputValue::from_php_mixed(&io.ask(prompt, PhpMixed::Null)?),
+ );
}
let repository_opt = input.borrow().get_option("repository")?;
diff --git a/crates/shirabe/src/command/depends_command.rs b/crates/shirabe/src/command/depends_command.rs
index f22682e8..25f7bfd9 100644
--- a/crates/shirabe/src/command/depends_command.rs
+++ b/crates/shirabe/src/command/depends_command.rs
@@ -67,7 +67,7 @@ impl Command for DependsCommand {
.into(),
InputOption::new(
crate::command::OPTION_RECURSIVE,
- Some(shirabe_php_shim::PhpMixed::String("r".to_string())),
+ Some("r"),
Some(InputOption::VALUE_NONE),
"Recursively resolves up to the root package",
None,
@@ -76,7 +76,7 @@ impl Command for DependsCommand {
.into(),
InputOption::new(
crate::command::OPTION_TREE,
- Some(shirabe_php_shim::PhpMixed::String("t".to_string())),
+ Some("t"),
Some(InputOption::VALUE_NONE),
"Prints the results as a nested tree",
None,
diff --git a/crates/shirabe/src/command/dump_autoload_command.rs b/crates/shirabe/src/command/dump_autoload_command.rs
index d9ac44ba..87acd74f 100644
--- a/crates/shirabe/src/command/dump_autoload_command.rs
+++ b/crates/shirabe/src/command/dump_autoload_command.rs
@@ -7,7 +7,7 @@ use crate::console::input::InputOption;
use crate::io::IOInterfaceImmutable;
use crate::plugin::CommandEvent;
use crate::plugin::PluginEvents;
-use shirabe_php_shim::{InvalidArgumentException, PhpMixed, file_exists, impl_php_class};
+use shirabe_php_shim::{InvalidArgumentException, file_exists, impl_php_class};
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::input::InputInterface;
use shirabe_symfony_console::output::OutputInterface;
@@ -43,8 +43,8 @@ impl Command for DumpAutoloadCommand {
self.set_aliases(vec!["dumpautoload".to_string()])?;
self.set_description("Dumps the autoloader");
self.set_definition(&[
- InputOption::new("optimize", Some(PhpMixed::String("o".to_string())), Some(InputOption::VALUE_NONE), "Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.", None).unwrap().into(),
- InputOption::new("classmap-authoritative", Some(PhpMixed::String("a".to_string())), Some(InputOption::VALUE_NONE), "Autoload classes from the classmap only. Implicitly enables `--optimize`.", None).unwrap().into(),
+ InputOption::new("optimize", Some("o"), Some(InputOption::VALUE_NONE), "Optimizes PSR0 and PSR4 packages to be loaded with classmaps too, good for production.", None).unwrap().into(),
+ InputOption::new("classmap-authoritative", Some("a"), Some(InputOption::VALUE_NONE), "Autoload classes from the classmap only. Implicitly enables `--optimize`.", None).unwrap().into(),
InputOption::new("apcu", None, Some(InputOption::VALUE_NONE), "Use APCu to cache found/not-found classes.", None).unwrap().into(),
InputOption::new("apcu-prefix", None, Some(InputOption::VALUE_REQUIRED), "Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu", None).unwrap().into(),
InputOption::new("dry-run", None, Some(InputOption::VALUE_NONE), "Outputs the operations but will not execute anything.", None).unwrap().into(),
diff --git a/crates/shirabe/src/command/exec_command.rs b/crates/shirabe/src/command/exec_command.rs
index 92e46c8b..7afab2ab 100644
--- a/crates/shirabe/src/command/exec_command.rs
+++ b/crates/shirabe/src/command/exec_command.rs
@@ -10,6 +10,7 @@ use crate::io::IOInterfaceImmutable;
use shirabe_php_shim::{PhpMixed, RuntimeException, basename, chdir, getcwd, glob, impl_php_class};
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
#[derive(Debug)]
@@ -78,7 +79,7 @@ impl Command for ExecCommand {
self.set_name("exec")?;
self.set_description("Executes a vendored binary/script");
self.set_definition(&[
- InputOption::new("list", Some(PhpMixed::String("l".to_string())), Some(InputOption::VALUE_NONE), "", None).unwrap().into(),
+ InputOption::new("list", Some("l"), Some(InputOption::VALUE_NONE), "", None).unwrap().into(),
// PHP passes an inline closure here (it takes no arguments; PHP tolerates the
// extra ones the caller passes).
InputArgument::new5("binary",
@@ -141,10 +142,9 @@ impl Command for ExecCommand {
)?;
if let Some(idx) = binary.as_int() {
- input.borrow_mut().set_argument(
- "binary",
- shirabe_php_shim::PhpMixed::String(binaries[idx as usize].clone()),
- );
+ input
+ .borrow_mut()
+ .set_argument("binary", InputValue::String(binaries[idx as usize].clone()));
}
Ok(())
@@ -230,12 +230,8 @@ impl Command for ExecCommand {
let args = input
.borrow()
.get_argument("args")?
- .as_list()
- .map(|l| {
- l.iter()
- .filter_map(|v| v.as_string().map(|s| s.to_string()))
- .collect::<Vec<_>>()
- })
+ .as_array()
+ .map(<[String]>::to_vec)
.unwrap_or_default();
dispatcher.borrow_mut().dispatch_script(
diff --git a/crates/shirabe/src/command/fund_command.rs b/crates/shirabe/src/command/fund_command.rs
index 089f69e8..9511cc31 100644
--- a/crates/shirabe/src/command/fund_command.rs
+++ b/crates/shirabe/src/command/fund_command.rs
@@ -16,6 +16,7 @@ use shirabe_semver::constraint::MatchAllConstraint;
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::formatter::OutputFormatter;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
#[derive(Debug)]
@@ -85,10 +86,10 @@ impl Command for FundCommand {
self.set_description("Discover how to help fund the maintenance of your dependencies");
self.set_definition(&[InputOption::new6(
"format",
- Some(PhpMixed::String("f".to_string())),
+ Some("f"),
Some(InputOption::VALUE_REQUIRED),
"Format of the output: text or json",
- Some(PhpMixed::String("text".to_string())),
+ Some(InputValue::String("text".to_string())),
SuggestedValues::List(vec!["text".to_string(), "json".to_string()]),
)
.unwrap()
diff --git a/crates/shirabe/src/command/global_command.rs b/crates/shirabe/src/command/global_command.rs
index f31d29c4..0e3606a4 100644
--- a/crates/shirabe/src/command/global_command.rs
+++ b/crates/shirabe/src/command/global_command.rs
@@ -185,7 +185,7 @@ impl Command for GlobalCommand {
return Ok(());
}
- let command_name = input.get_argument("command-name")?.to_string();
+ let command_name = input.get_argument("command-name")?.to_php_string();
let has = {
let mut app_ref = application.borrow_mut();
let app = app_ref
diff --git a/crates/shirabe/src/command/home_command.rs b/crates/shirabe/src/command/home_command.rs
index c147bb68..015b6cf2 100644
--- a/crates/shirabe/src/command/home_command.rs
+++ b/crates/shirabe/src/command/home_command.rs
@@ -144,7 +144,7 @@ impl Command for HomeCommand {
.into(),
InputOption::new(
"homepage",
- Some(shirabe_php_shim::PhpMixed::String("H".to_string())),
+ Some("H"),
Some(InputOption::VALUE_NONE),
"Open the homepage instead of the repository URL.",
None,
@@ -153,7 +153,7 @@ impl Command for HomeCommand {
.into(),
InputOption::new(
"show",
- Some(shirabe_php_shim::PhpMixed::String("s".to_string())),
+ Some("s"),
Some(InputOption::VALUE_NONE),
"Only show the homepage or repository URL.",
None,
@@ -183,12 +183,8 @@ impl Command for HomeCommand {
let packages: Vec<String> = input
.borrow()
.get_argument("packages")?
- .as_list()
- .map(|l| {
- l.iter()
- .filter_map(|v| v.as_string().map(|s| s.to_string()))
- .collect()
- })
+ .as_array()
+ .map(<[String]>::to_vec)
.unwrap_or_default();
let packages = if packages.is_empty() {
diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs
index d1b5dbe5..9399c2a7 100644
--- a/crates/shirabe/src/command/init_command.rs
+++ b/crates/shirabe/src/command/init_command.rs
@@ -32,6 +32,7 @@ use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::helper::FormatBlockMessages;
use shirabe_symfony_console::input::ArrayInput;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
#[derive(Debug)]
@@ -444,10 +445,10 @@ impl Command for InitCommand {
InputOption::new("homepage", None, Some(InputOption::VALUE_REQUIRED), "Homepage of package", None).unwrap().into(),
InputOption::new6("require", None, Some(InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED), "Package to require with a version constraint, e.g. foo/bar:1.0.0 or foo/bar=1.0.0 or \"foo/bar 1.0.0\"", None, self.suggest_available_package_incl_platform()).unwrap().into(),
InputOption::new6("require-dev", None, Some(InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED), "Package to require for development with a version constraint, e.g. foo/bar:1.0.0 or foo/bar=1.0.0 or \"foo/bar 1.0.0\"", None, self.suggest_available_package_incl_platform()).unwrap().into(),
- InputOption::new("stability", Some(PhpMixed::String("s".to_string())), Some(InputOption::VALUE_REQUIRED), &format!("Minimum stability (empty or one of: {})", implode(", ", &base_package::STABILITIES.keys().map(|k| k.to_string()).collect::<Vec<_>>())), None).unwrap().into(),
- InputOption::new("license", Some(PhpMixed::String("l".to_string())), Some(InputOption::VALUE_REQUIRED), "License of package", None).unwrap().into(),
+ InputOption::new("stability", Some("s"), Some(InputOption::VALUE_REQUIRED), &format!("Minimum stability (empty or one of: {})", implode(", ", &base_package::STABILITIES.keys().map(|k| k.to_string()).collect::<Vec<_>>())), None).unwrap().into(),
+ InputOption::new("license", Some("l"), Some(InputOption::VALUE_REQUIRED), "License of package", None).unwrap().into(),
InputOption::new("repository", None, Some(InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY), "Add custom repositories, either by URL or using JSON arrays", None).unwrap().into(),
- InputOption::new("autoload", Some(PhpMixed::String("a".to_string())), Some(InputOption::VALUE_REQUIRED), "Add PSR-4 autoload mapping. Maps your package's namespace to the provided directory. (Expects a relative path, e.g. src/)", None).unwrap().into(),
+ InputOption::new("autoload", Some("a"), Some(InputOption::VALUE_REQUIRED), "Add PSR-4 autoload mapping. Maps your package's namespace to the provided directory. (Expects a relative path, e.g. src/)", None).unwrap().into(),
]);
self.set_help(
"The <info>init</info> command creates a basic composer.json file\n\
@@ -480,12 +481,16 @@ impl Command for InitCommand {
"license".to_string(),
"autoload".to_string(),
];
- let filtered_input: IndexMap<String, PhpMixed> = array_intersect_key(
- &input.borrow().get_options(),
- &array_flip_strings(&allowlist),
- )
- .into_iter()
- .collect();
+ let options: IndexMap<String, PhpMixed> = input
+ .borrow()
+ .get_options()
+ .into_iter()
+ .map(|(key, value)| (key, value.to_php_mixed()))
+ .collect();
+ let filtered_input: IndexMap<String, PhpMixed> =
+ array_intersect_key(&options, &array_flip_strings(&allowlist))
+ .into_iter()
+ .collect();
let mut options = shirabe_php_shim::array_filter_map(&filtered_input, |val: &PhpMixed| {
!matches!(val, PhpMixed::Null) && !matches!(val, PhpMixed::List(l) if l.is_empty())
});
@@ -752,7 +757,7 @@ impl Command for InitCommand {
let name = self.get_default_package_name()?;
input
.borrow_mut()
- .set_option("name", PhpMixed::from(name))
+ .set_option("name", InputValue::from(name))
.expect("name option is defined");
}
@@ -760,7 +765,7 @@ impl Command for InitCommand {
let author = self.get_default_author()?;
input
.borrow_mut()
- .set_option("author", PhpMixed::from(author))
+ .set_option("author", InputValue::from(author))
.expect("author option is defined");
}
}
@@ -919,7 +924,7 @@ impl Command for InitCommand {
.to_string();
input
.borrow_mut()
- .set_option("name", PhpMixed::String(name));
+ .set_option("name", InputValue::String(name));
let description = input
.borrow()
@@ -936,7 +941,9 @@ impl Command for InitCommand {
.map(PhpMixed::String)
.unwrap_or(PhpMixed::Null),
)?;
- input.borrow_mut().set_option("description", description);
+ input
+ .borrow_mut()
+ .set_option("description", InputValue::from_php_mixed(&description));
let author_option = input
.borrow()
@@ -984,7 +991,9 @@ impl Command for InitCommand {
None,
PhpMixed::String(author_default),
)?;
- input.borrow_mut().set_option("author", author_value);
+ input
+ .borrow_mut()
+ .set_option("author", InputValue::from_php_mixed(&author_value));
let minimum_stability = input
.borrow()
@@ -1029,9 +1038,10 @@ impl Command for InitCommand {
.map(PhpMixed::String)
.unwrap_or(PhpMixed::Null),
)?;
- input
- .borrow_mut()
- .set_option("stability", minimum_stability_value);
+ input.borrow_mut().set_option(
+ "stability",
+ InputValue::from_php_mixed(&minimum_stability_value),
+ );
let type_val = input.borrow().get_option("type")?;
let type_str = type_val.as_string().unwrap_or("").to_string();
@@ -1045,7 +1055,9 @@ impl Command for InitCommand {
if type_value.as_string() == Some("") || matches!(type_value, PhpMixed::Bool(false)) {
type_value = PhpMixed::Null;
}
- input.borrow_mut().set_option("type", type_value);
+ input
+ .borrow_mut()
+ .set_option("type", InputValue::from_php_mixed(&type_value));
let mut license = input
.borrow()
@@ -1086,7 +1098,9 @@ impl Command for InitCommand {
))
.into());
}
- input.borrow_mut().set_option("license", license);
+ input
+ .borrow_mut()
+ .set_option("license", InputValue::from_php_mixed(&license));
io.write_error3("\nDefine your dependencies.\n", true, io_interface::NORMAL);
@@ -1135,10 +1149,9 @@ impl Command for InitCommand {
} else {
vec![]
};
- input.borrow_mut().set_option(
- "require",
- PhpMixed::List(requirements.into_iter().map(PhpMixed::String).collect()),
- );
+ input
+ .borrow_mut()
+ .set_option("require", InputValue::Array(requirements));
let question = "Would you like to define your dev dependencies (require-dev) interactively [<comment>yes</comment>]? ".to_string();
let require_dev: Vec<String> = input
@@ -1161,10 +1174,9 @@ impl Command for InitCommand {
} else {
vec![]
};
- input.borrow_mut().set_option(
- "require-dev",
- PhpMixed::List(dev_requirements.into_iter().map(PhpMixed::String).collect()),
- );
+ input
+ .borrow_mut()
+ .set_option("require-dev", InputValue::Array(dev_requirements));
// --autoload - input and validation
let autoload = input
@@ -1220,7 +1232,9 @@ impl Command for InitCommand {
None,
PhpMixed::String(autoload_default),
)?;
- input.borrow_mut().set_option("autoload", autoload_value);
+ input
+ .borrow_mut()
+ .set_option("autoload", InputValue::from_php_mixed(&autoload_value));
Ok(())
})();
diff --git a/crates/shirabe/src/command/install_command.rs b/crates/shirabe/src/command/install_command.rs
index f1a6df35..1431fb57 100644
--- a/crates/shirabe/src/command/install_command.rs
+++ b/crates/shirabe/src/command/install_command.rs
@@ -13,9 +13,10 @@ use crate::io::IOInterfaceImmutable;
use crate::plugin::CommandEvent;
use crate::plugin::PluginEvents;
use crate::util::HttpDownloader;
-use shirabe_php_shim::{PhpMixed, impl_php_class};
+use shirabe_php_shim::impl_php_class;
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
#[derive(Debug)]
@@ -62,10 +63,10 @@ impl Command for InstallCommand {
InputOption::new("no-progress", None, Some(InputOption::VALUE_NONE), "Do not output download progress.", None).unwrap().into(),
InputOption::new("no-install", None, Some(InputOption::VALUE_NONE), "Do not use, only defined here to catch misuse of the install command.", None).unwrap().into(),
InputOption::new("audit", None, Some(InputOption::VALUE_NONE), "Run an audit after installation is complete.", None).unwrap().into(),
- InputOption::new6("audit-format", None, Some(InputOption::VALUE_REQUIRED), "Audit output format. Must be \"table\", \"plain\", \"json\", or \"summary\".", Some(PhpMixed::String(Auditor::FORMAT_SUMMARY.to_string())), SuggestedValues::List(Auditor::FORMATS.iter().map(|s| s.to_string()).collect())).unwrap().into(),
- InputOption::new("verbose", Some(PhpMixed::String("v|vv|vvv".to_string())), Some(InputOption::VALUE_NONE), "Shows more details including new commits pulled in when updating packages.", None).unwrap().into(),
- InputOption::new("optimize-autoloader", Some(PhpMixed::String("o".to_string())), Some(InputOption::VALUE_NONE), "Optimize autoloader during autoloader dump", None).unwrap().into(),
- InputOption::new("classmap-authoritative", Some(PhpMixed::String("a".to_string())), Some(InputOption::VALUE_NONE), "Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.", None).unwrap().into(),
+ InputOption::new6("audit-format", None, Some(InputOption::VALUE_REQUIRED), "Audit output format. Must be \"table\", \"plain\", \"json\", or \"summary\".", Some(InputValue::String(Auditor::FORMAT_SUMMARY.to_string())), SuggestedValues::List(Auditor::FORMATS.iter().map(|s| s.to_string()).collect())).unwrap().into(),
+ InputOption::new("verbose", Some("v|vv|vvv"), Some(InputOption::VALUE_NONE), "Shows more details including new commits pulled in when updating packages.", None).unwrap().into(),
+ InputOption::new("optimize-autoloader", Some("o"), Some(InputOption::VALUE_NONE), "Optimize autoloader during autoloader dump", None).unwrap().into(),
+ InputOption::new("classmap-authoritative", Some("a"), Some(InputOption::VALUE_NONE), "Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.", None).unwrap().into(),
InputOption::new("apcu-autoloader", None, Some(InputOption::VALUE_NONE), "Use APCu to cache found/not-found classes.", None).unwrap().into(),
InputOption::new("apcu-autoloader-prefix", None, Some(InputOption::VALUE_REQUIRED), "Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader", None).unwrap().into(),
InputOption::new("ignore-platform-req", None, Some(InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY), "Ignore a specific platform requirement (php & ext- packages).", None).unwrap().into(),
@@ -103,14 +104,7 @@ impl Command for InstallCommand {
}
let args = input.borrow().get_argument("packages")?;
- let args_vec: Vec<String> = args
- .as_list()
- .map(|l| {
- l.iter()
- .filter_map(|v| v.as_string().map(|s| s.to_string()))
- .collect()
- })
- .unwrap_or_default();
+ let args_vec: Vec<String> = args.as_array().map(<[String]>::to_vec).unwrap_or_default();
if !args_vec.is_empty() {
io.write_error(&format!(
"<error>Invalid argument {}. Use \"composer require {}\" instead to add packages to your composer.json.</error>",
diff --git a/crates/shirabe/src/command/licenses_command.rs b/crates/shirabe/src/command/licenses_command.rs
index 4087e6e3..4270c03d 100644
--- a/crates/shirabe/src/command/licenses_command.rs
+++ b/crates/shirabe/src/command/licenses_command.rs
@@ -19,6 +19,7 @@ use shirabe_symfony_console::formatter::OutputFormatter;
use shirabe_symfony_console::helper::Row;
use shirabe_symfony_console::helper::Table;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
use shirabe_symfony_console::style::StyleInterface;
use shirabe_symfony_console::style::SymfonyStyle;
@@ -55,10 +56,10 @@ impl Command for LicensesCommand {
self.set_definition(&[
InputOption::new6(
"format",
- Some(PhpMixed::String("f".to_string())),
+ Some("f"),
Some(InputOption::VALUE_REQUIRED),
"Format of the output: text, json or summary",
- Some(PhpMixed::String("text".to_string())),
+ Some(InputValue::String("text".to_string())),
SuggestedValues::List(vec![
"text".to_string(),
"json".to_string(),
diff --git a/crates/shirabe/src/command/outdated_command.rs b/crates/shirabe/src/command/outdated_command.rs
index a89a1cd8..b32fccdf 100644
--- a/crates/shirabe/src/command/outdated_command.rs
+++ b/crates/shirabe/src/command/outdated_command.rs
@@ -8,10 +8,12 @@ use crate::console::input::InputArgument;
use crate::console::input::InputOption;
use crate::console::input::SuggestedValues;
use indexmap::IndexMap;
-use shirabe_php_shim::{PhpMixed, impl_php_class};
+use shirabe_php_shim::impl_php_class;
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::input::ArrayInput;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
+use shirabe_symfony_console::input::ParameterName;
use shirabe_symfony_console::output::OutputInterface;
#[derive(Debug)]
@@ -45,16 +47,16 @@ impl Command for OutdatedCommand {
self.set_description("Shows a list of installed packages that have updates available, including their latest version");
self.set_definition(&[
InputArgument::new5("package", Some(InputArgument::OPTIONAL), "Package to inspect. Or a name including a wildcard (*) to filter lists of packages instead.", None, self.suggest_installed_package(false, false)).unwrap().into(),
- InputOption::new("outdated", Some(PhpMixed::String("o".to_string())), Some(InputOption::VALUE_NONE), "Show only packages that are outdated (this is the default, but present here for compat with `show`", None).unwrap().into(),
- InputOption::new("all", Some(PhpMixed::String("a".to_string())), Some(InputOption::VALUE_NONE), "Show all installed packages with their latest versions", None).unwrap().into(),
+ InputOption::new("outdated", Some("o"), Some(InputOption::VALUE_NONE), "Show only packages that are outdated (this is the default, but present here for compat with `show`", None).unwrap().into(),
+ InputOption::new("all", Some("a"), Some(InputOption::VALUE_NONE), "Show all installed packages with their latest versions", None).unwrap().into(),
InputOption::new("locked", None, Some(InputOption::VALUE_NONE), "Shows updates for packages from the lock file, regardless of what is currently in vendor dir", None).unwrap().into(),
- InputOption::new("direct", Some(PhpMixed::String("D".to_string())), Some(InputOption::VALUE_NONE), "Shows only packages that are directly required by the root package", None).unwrap().into(),
+ InputOption::new("direct", Some("D"), Some(InputOption::VALUE_NONE), "Shows only packages that are directly required by the root package", None).unwrap().into(),
InputOption::new("strict", None, Some(InputOption::VALUE_NONE), "Return a non-zero exit code when there are outdated packages", None).unwrap().into(),
- InputOption::new("major-only", Some(PhpMixed::String("M".to_string())), Some(InputOption::VALUE_NONE), "Show only packages that have major SemVer-compatible updates.", None).unwrap().into(),
- InputOption::new("minor-only", Some(PhpMixed::String("m".to_string())), Some(InputOption::VALUE_NONE), "Show only packages that have minor SemVer-compatible updates.", None).unwrap().into(),
- InputOption::new("patch-only", Some(PhpMixed::String("p".to_string())), Some(InputOption::VALUE_NONE), "Show only packages that have patch SemVer-compatible updates.", None).unwrap().into(),
- InputOption::new("sort-by-age", Some(PhpMixed::String("A".to_string())), Some(InputOption::VALUE_NONE), "Displays the installed version's age, and sorts packages oldest first.", None).unwrap().into(),
- InputOption::new6("format", Some(PhpMixed::String("f".to_string())), Some(InputOption::VALUE_REQUIRED), "Format of the output: text or json", Some(PhpMixed::String("text".to_string())), SuggestedValues::List(vec!["json".to_string(), "text".to_string()])).unwrap().into(),
+ InputOption::new("major-only", Some("M"), Some(InputOption::VALUE_NONE), "Show only packages that have major SemVer-compatible updates.", None).unwrap().into(),
+ InputOption::new("minor-only", Some("m"), Some(InputOption::VALUE_NONE), "Show only packages that have minor SemVer-compatible updates.", None).unwrap().into(),
+ InputOption::new("patch-only", Some("p"), Some(InputOption::VALUE_NONE), "Show only packages that have patch SemVer-compatible updates.", None).unwrap().into(),
+ InputOption::new("sort-by-age", Some("A"), Some(InputOption::VALUE_NONE), "Displays the installed version's age, and sorts packages oldest first.", None).unwrap().into(),
+ InputOption::new6("format", Some("f"), Some(InputOption::VALUE_REQUIRED), "Format of the output: text or json", Some(InputValue::String("text".to_string())), SuggestedValues::List(vec!["json".to_string(), "text".to_string()])).unwrap().into(),
InputOption::new6("ignore", None, Some(InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY), "Ignore specified package(s). Can contain wildcards (*). Use it if you don't want to be informed about new versions of some packages.", None, self.suggest_installed_package(false, false)).unwrap().into(),
InputOption::new("no-dev", None, Some(InputOption::VALUE_NONE), "Disables search in require-dev packages.", None).unwrap().into(),
InputOption::new("ignore-platform-req", None, Some(InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY), "Ignore a specific platform requirement (php & ext- packages). Use with the --outdated option", None).unwrap().into(),
@@ -78,9 +80,12 @@ impl Command for OutdatedCommand {
input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
) -> anyhow::Result<i64> {
- let mut args: IndexMap<String, PhpMixed> = IndexMap::new();
- args.insert("command".to_string(), PhpMixed::String("show".to_string()));
- args.insert("--latest".to_string(), PhpMixed::Bool(true));
+ let mut args: IndexMap<String, InputValue> = IndexMap::new();
+ args.insert(
+ "command".to_string(),
+ InputValue::String("show".to_string()),
+ );
+ args.insert("--latest".to_string(), InputValue::Bool(true));
if input
.borrow()
@@ -88,7 +93,7 @@ impl Command for OutdatedCommand {
.as_bool()
.unwrap_or(false)
{
- args.insert("--no-interaction".to_string(), PhpMixed::Bool(true));
+ args.insert("--no-interaction".to_string(), InputValue::Bool(true));
}
if input
.borrow()
@@ -96,7 +101,7 @@ impl Command for OutdatedCommand {
.as_bool()
.unwrap_or(false)
{
- args.insert("--no-plugins".to_string(), PhpMixed::Bool(true));
+ args.insert("--no-plugins".to_string(), InputValue::Bool(true));
}
if input
.borrow()
@@ -104,7 +109,7 @@ impl Command for OutdatedCommand {
.as_bool()
.unwrap_or(false)
{
- args.insert("--no-scripts".to_string(), PhpMixed::Bool(true));
+ args.insert("--no-scripts".to_string(), InputValue::Bool(true));
}
if input
.borrow()
@@ -112,10 +117,10 @@ impl Command for OutdatedCommand {
.as_bool()
.unwrap_or(false)
{
- args.insert("--no-cache".to_string(), PhpMixed::Bool(true));
+ args.insert("--no-cache".to_string(), InputValue::Bool(true));
}
if !input.borrow().get_option("all")?.as_bool().unwrap_or(false) {
- args.insert("--outdated".to_string(), PhpMixed::Bool(true));
+ args.insert("--outdated".to_string(), InputValue::Bool(true));
}
if input
.borrow()
@@ -123,10 +128,10 @@ impl Command for OutdatedCommand {
.as_bool()
.unwrap_or(false)
{
- args.insert("--direct".to_string(), PhpMixed::Bool(true));
+ args.insert("--direct".to_string(), InputValue::Bool(true));
}
let package_arg = input.borrow().get_argument("package")?;
- if !matches!(package_arg, PhpMixed::Null) {
+ if !package_arg.is_null() {
args.insert("package".to_string(), package_arg);
}
if input
@@ -135,7 +140,7 @@ impl Command for OutdatedCommand {
.as_bool()
.unwrap_or(false)
{
- args.insert("--strict".to_string(), PhpMixed::Bool(true));
+ args.insert("--strict".to_string(), InputValue::Bool(true));
}
if input
.borrow()
@@ -143,7 +148,7 @@ impl Command for OutdatedCommand {
.as_bool()
.unwrap_or(false)
{
- args.insert("--major-only".to_string(), PhpMixed::Bool(true));
+ args.insert("--major-only".to_string(), InputValue::Bool(true));
}
if input
.borrow()
@@ -151,7 +156,7 @@ impl Command for OutdatedCommand {
.as_bool()
.unwrap_or(false)
{
- args.insert("--minor-only".to_string(), PhpMixed::Bool(true));
+ args.insert("--minor-only".to_string(), InputValue::Bool(true));
}
if input
.borrow()
@@ -159,7 +164,7 @@ impl Command for OutdatedCommand {
.as_bool()
.unwrap_or(false)
{
- args.insert("--patch-only".to_string(), PhpMixed::Bool(true));
+ args.insert("--patch-only".to_string(), InputValue::Bool(true));
}
if input
.borrow()
@@ -167,7 +172,7 @@ impl Command for OutdatedCommand {
.as_bool()
.unwrap_or(false)
{
- args.insert("--locked".to_string(), PhpMixed::Bool(true));
+ args.insert("--locked".to_string(), InputValue::Bool(true));
}
if input
.borrow()
@@ -175,7 +180,7 @@ impl Command for OutdatedCommand {
.as_bool()
.unwrap_or(false)
{
- args.insert("--no-dev".to_string(), PhpMixed::Bool(true));
+ args.insert("--no-dev".to_string(), InputValue::Bool(true));
}
if input
.borrow()
@@ -183,11 +188,11 @@ impl Command for OutdatedCommand {
.as_bool()
.unwrap_or(false)
{
- args.insert("--sort-by-age".to_string(), PhpMixed::Bool(true));
+ args.insert("--sort-by-age".to_string(), InputValue::Bool(true));
}
args.insert(
"--ignore-platform-req".to_string(),
- input.borrow().get_option("ignore-platform-req")?.into(),
+ input.borrow().get_option("ignore-platform-req")?,
);
if input
.borrow()
@@ -195,20 +200,14 @@ impl Command for OutdatedCommand {
.as_bool()
.unwrap_or(false)
{
- args.insert("--ignore-platform-reqs".to_string(), PhpMixed::Bool(true));
+ args.insert("--ignore-platform-reqs".to_string(), InputValue::Bool(true));
}
- args.insert(
- "--format".to_string(),
- input.borrow().get_option("format")?.into(),
- );
- args.insert(
- "--ignore".to_string(),
- input.borrow().get_option("ignore")?.into(),
- );
+ args.insert("--format".to_string(), input.borrow().get_option("format")?);
+ args.insert("--ignore".to_string(), input.borrow().get_option("ignore")?);
let input = ArrayInput::new(
args.into_iter()
- .map(|(k, v)| (PhpMixed::String(k), v))
+ .map(|(k, v)| (ParameterName::Name(k), v))
.collect(),
None,
)?;
diff --git a/crates/shirabe/src/command/prohibits_command.rs b/crates/shirabe/src/command/prohibits_command.rs
index ae38f9d2..c7579efb 100644
--- a/crates/shirabe/src/command/prohibits_command.rs
+++ b/crates/shirabe/src/command/prohibits_command.rs
@@ -74,7 +74,7 @@ impl Command for ProhibitsCommand {
.into(),
InputOption::new(
<Self as BaseDependencyCommand>::OPTION_RECURSIVE,
- Some(shirabe_php_shim::PhpMixed::String("r".to_string())),
+ Some("r"),
Some(InputOption::VALUE_NONE),
"Recursively resolves up to the root package",
None,
@@ -83,7 +83,7 @@ impl Command for ProhibitsCommand {
.into(),
InputOption::new(
<Self as BaseDependencyCommand>::OPTION_TREE,
- Some(shirabe_php_shim::PhpMixed::String("t".to_string())),
+ Some("t"),
Some(InputOption::VALUE_NONE),
"Prints the results as a nested tree",
None,
diff --git a/crates/shirabe/src/command/reinstall_command.rs b/crates/shirabe/src/command/reinstall_command.rs
index 43978191..aa98e89f 100644
--- a/crates/shirabe/src/command/reinstall_command.rs
+++ b/crates/shirabe/src/command/reinstall_command.rs
@@ -55,8 +55,8 @@ impl Command for ReinstallCommand {
InputOption::new6("prefer-install", None, Some(InputOption::VALUE_REQUIRED), "Forces installation from package dist|source|auto (auto chooses source for dev versions, dist for the rest).", None, self.suggest_prefer_install()).unwrap().into(),
InputOption::new("no-autoloader", None, Some(InputOption::VALUE_NONE), "Skips autoloader generation", None).unwrap().into(),
InputOption::new("no-progress", None, Some(InputOption::VALUE_NONE), "Do not output download progress.", None).unwrap().into(),
- InputOption::new("optimize-autoloader", Some(shirabe_php_shim::PhpMixed::String("o".to_string())), Some(InputOption::VALUE_NONE), "Optimize autoloader during autoloader dump", None).unwrap().into(),
- InputOption::new("classmap-authoritative", Some(shirabe_php_shim::PhpMixed::String("a".to_string())), Some(InputOption::VALUE_NONE), "Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.", None).unwrap().into(),
+ InputOption::new("optimize-autoloader", Some("o"), Some(InputOption::VALUE_NONE), "Optimize autoloader during autoloader dump", None).unwrap().into(),
+ InputOption::new("classmap-authoritative", Some("a"), Some(InputOption::VALUE_NONE), "Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.", None).unwrap().into(),
InputOption::new("apcu-autoloader", None, Some(InputOption::VALUE_NONE), "Use APCu to cache found/not-found classes.", None).unwrap().into(),
InputOption::new("apcu-autoloader-prefix", None, Some(InputOption::VALUE_REQUIRED), "Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader", None).unwrap().into(),
InputOption::new("ignore-platform-req", None, Some(InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY), "Ignore a specific platform requirement (php & ext- packages).", None).unwrap().into(),
@@ -93,7 +93,7 @@ impl Command for ReinstallCommand {
let type_option = input.borrow().get_option("type")?;
let type_count = type_option.as_array().map_or(0, <[String]>::len);
let packages_arg = input.borrow().get_argument("packages")?;
- let packages_count = packages_arg.as_list().map_or(0, |l| l.len());
+ let packages_count = packages_arg.as_array().map_or(0, <[String]>::len);
if type_count > 0 {
if packages_count > 0 {
@@ -121,12 +121,8 @@ impl Command for ReinstallCommand {
.into());
}
let patterns: Vec<String> = packages_arg
- .as_list()
- .map(|l| {
- l.iter()
- .filter_map(|v| v.as_string().map(|s| s.to_string()))
- .collect()
- })
+ .as_array()
+ .map(<[String]>::to_vec)
.unwrap_or_default();
for pattern in &patterns {
let pattern_regexp = base_package::package_name_to_regexp(pattern);
diff --git a/crates/shirabe/src/command/remove_command.rs b/crates/shirabe/src/command/remove_command.rs
index 7eb88f2b..9004a9fd 100644
--- a/crates/shirabe/src/command/remove_command.rs
+++ b/crates/shirabe/src/command/remove_command.rs
@@ -21,6 +21,7 @@ use shirabe_php_shim::{PhpMixed, UnexpectedValueException, impl_php_class, preg_
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::exception::InvalidArgumentException;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
#[derive(Debug)]
@@ -93,7 +94,7 @@ impl Command for RemoveCommand {
None,
Some(InputOption::VALUE_REQUIRED),
"Audit output format. Must be \"table\", \"plain\", \"json\", or \"summary\".",
- Some(PhpMixed::String(Auditor::FORMAT_SUMMARY.to_string())),
+ Some(InputValue::String(Auditor::FORMAT_SUMMARY.to_string())),
SuggestedValues::List(Auditor::FORMATS.iter().map(|s| s.to_string()).collect())).unwrap().into(),
InputOption::new("no-security-blocking",
None,
@@ -106,12 +107,12 @@ impl Command for RemoveCommand {
"Run the dependency update with the --no-dev option.",
None).unwrap().into(),
InputOption::new("update-with-dependencies",
- Some(PhpMixed::String("w".to_string())),
+ Some("w"),
Some(InputOption::VALUE_NONE),
"Allows inherited dependencies to be updated with explicit dependencies (can also be set via the COMPOSER_WITH_DEPENDENCIES=1 env var). (Deprecated, is now default behavior)",
None).unwrap().into(),
InputOption::new("update-with-all-dependencies",
- Some(PhpMixed::String("W".to_string())),
+ Some("W"),
Some(InputOption::VALUE_NONE),
"Allows all inherited dependencies to be updated, including those that are root requirements (can also be set via the COMPOSER_WITH_ALL_DEPENDENCIES=1 env var).",
None).unwrap().into(),
@@ -126,7 +127,7 @@ impl Command for RemoveCommand {
"Does not allow inherited dependencies to be updated with explicit dependencies.",
None).unwrap().into(),
InputOption::new("minimal-changes",
- Some(PhpMixed::String("m".to_string())),
+ Some("m"),
Some(InputOption::VALUE_NONE),
"During an update with -w/-W, only perform absolutely necessary changes to transitive dependencies (can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var).",
None).unwrap().into(),
@@ -146,12 +147,12 @@ impl Command for RemoveCommand {
"Ignore all platform requirements (php & ext- packages).",
None).unwrap().into(),
InputOption::new("optimize-autoloader",
- Some(PhpMixed::String("o".to_string())),
+ Some("o"),
Some(InputOption::VALUE_NONE),
"Optimize autoloader during autoloader dump",
None).unwrap().into(),
InputOption::new("classmap-authoritative",
- Some(PhpMixed::String("a".to_string())),
+ Some("a"),
Some(InputOption::VALUE_NONE),
"Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.",
None).unwrap().into(),
@@ -183,8 +184,8 @@ impl Command for RemoveCommand {
if input
.borrow()
.get_argument("packages")?
- .as_list()
- .map(|l| l.is_empty())
+ .as_array()
+ .map(<[String]>::is_empty)
.unwrap_or(true)
&& !input
.borrow()
@@ -201,12 +202,8 @@ impl Command for RemoveCommand {
let mut packages: Vec<String> = input
.borrow()
.get_argument("packages")?
- .as_list()
- .map(|l| {
- l.iter()
- .filter_map(|v| v.as_string().map(strtolower))
- .collect()
- })
+ .as_array()
+ .map(|l| l.iter().map(|v| strtolower(v)).collect())
.unwrap_or_default();
if input
diff --git a/crates/shirabe/src/command/repository_command.rs b/crates/shirabe/src/command/repository_command.rs
index 8f68b16b..4cf0c981 100644
--- a/crates/shirabe/src/command/repository_command.rs
+++ b/crates/shirabe/src/command/repository_command.rs
@@ -16,6 +16,7 @@ use shirabe_php_shim::{
};
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
#[derive(Debug)]
@@ -128,7 +129,7 @@ impl RepositoryCommand {
/// PHP: private function suggestTypeForAdd(): \Closure (a static closure — `this` unused)
fn suggest_type_for_add(&self) -> crate::console::input::SuggestedValues {
crate::console::input::SuggestedValues::Closure(Box::new(|_this, input, _suggestions| {
- if input.get_argument("action")?.to_string() == "add" {
+ if input.get_argument("action")?.to_php_string() == "add" {
return Ok(vec![
"composer".to_string(),
"vcs".to_string(),
@@ -143,7 +144,7 @@ impl RepositoryCommand {
fn suggest_repo_names(&self) -> crate::console::input::SuggestedValues {
crate::console::input::SuggestedValues::Closure(Box::new(|this, input, _suggestions| {
- let action = input.get_argument("action")?.to_string();
+ let action = input.get_argument("action")?.to_php_string();
if ["enable", "disable"].contains(&action.as_str()) {
return Ok(vec!["packagist.org".to_string()]);
}
@@ -202,7 +203,7 @@ impl Command for RepositoryCommand {
self.set_definition(&[
InputOption::new(
"global",
- Some(PhpMixed::String("g".to_string())),
+ Some("g"),
Some(InputOption::VALUE_NONE),
"Apply command to the global config file",
None,
@@ -211,7 +212,7 @@ impl Command for RepositoryCommand {
.into(),
InputOption::new(
"file",
- Some(PhpMixed::String("f".to_string())),
+ Some("f"),
Some(InputOption::VALUE_REQUIRED),
"If you want to choose a different composer.json or config.json",
None,
@@ -251,7 +252,7 @@ impl Command for RepositoryCommand {
"action",
Some(InputArgument::OPTIONAL),
"Action to perform: list, add, remove, set-url, get-url, enable, disable",
- Some(PhpMixed::String("list".to_string())),
+ Some(InputValue::String("list".to_string())),
crate::console::input::SuggestedValues::List(vec![
"list".to_string(),
"add".to_string(),
diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs
index f06c4d84..15eae91b 100644
--- a/crates/shirabe/src/command/require_command.rs
+++ b/crates/shirabe/src/command/require_command.rs
@@ -40,6 +40,7 @@ use shirabe_php_shim::{
};
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
#[derive(Debug)]
@@ -440,12 +441,8 @@ impl RequireCommand {
input
.borrow()
.get_argument("packages")?
- .as_list()
- .map(|l| {
- l.iter()
- .filter_map(|v| v.as_string().map(|s| s.to_string()))
- .collect()
- })
+ .as_array()
+ .map(<[String]>::to_vec)
.unwrap_or_default(),
)? {
if !req.contains_key("version") {
@@ -753,21 +750,21 @@ impl Command for RequireCommand {
InputOption::new("no-update", None, Some(InputOption::VALUE_NONE), "Disables the automatic update of the dependencies (implies --no-install).", None).unwrap().into(),
InputOption::new("no-install", None, Some(InputOption::VALUE_NONE), "Skip the install step after updating the composer.lock file.", None).unwrap().into(),
InputOption::new("no-audit", None, Some(InputOption::VALUE_NONE), "Skip the audit step after updating the composer.lock file (can also be set via the COMPOSER_NO_AUDIT=1 env var).", None).unwrap().into(),
- InputOption::new6("audit-format", None, Some(InputOption::VALUE_REQUIRED), "Audit output format. Must be \"table\", \"plain\", \"json\", or \"summary\".", Some(PhpMixed::String(Auditor::FORMAT_SUMMARY.to_string())), SuggestedValues::List(Auditor::FORMATS.iter().map(|s| s.to_string()).collect())).unwrap().into(),
+ InputOption::new6("audit-format", None, Some(InputOption::VALUE_REQUIRED), "Audit output format. Must be \"table\", \"plain\", \"json\", or \"summary\".", Some(InputValue::String(Auditor::FORMAT_SUMMARY.to_string())), SuggestedValues::List(Auditor::FORMATS.iter().map(|s| s.to_string()).collect())).unwrap().into(),
InputOption::new("no-security-blocking", None, Some(InputOption::VALUE_NONE), "Allows installing packages with security advisories or that are abandoned (can also be set via the COMPOSER_NO_SECURITY_BLOCKING=1 env var).", None).unwrap().into(),
InputOption::new("update-no-dev", None, Some(InputOption::VALUE_NONE), "Run the dependency update with the --no-dev option.", None).unwrap().into(),
- InputOption::new("update-with-dependencies", Some(PhpMixed::String("w".to_string())), Some(InputOption::VALUE_NONE), "Allows inherited dependencies to be updated, except those that are root requirements (can also be set via the COMPOSER_WITH_DEPENDENCIES=1 env var).", None).unwrap().into(),
- InputOption::new("update-with-all-dependencies", Some(PhpMixed::String("W".to_string())), Some(InputOption::VALUE_NONE), "Allows all inherited dependencies to be updated, including those that are root requirements (can also be set via the COMPOSER_WITH_ALL_DEPENDENCIES=1 env var).", None).unwrap().into(),
+ InputOption::new("update-with-dependencies", Some("w"), Some(InputOption::VALUE_NONE), "Allows inherited dependencies to be updated, except those that are root requirements (can also be set via the COMPOSER_WITH_DEPENDENCIES=1 env var).", None).unwrap().into(),
+ InputOption::new("update-with-all-dependencies", Some("W"), Some(InputOption::VALUE_NONE), "Allows all inherited dependencies to be updated, including those that are root requirements (can also be set via the COMPOSER_WITH_ALL_DEPENDENCIES=1 env var).", None).unwrap().into(),
InputOption::new("with-dependencies", None, Some(InputOption::VALUE_NONE), "Alias for --update-with-dependencies", None).unwrap().into(),
InputOption::new("with-all-dependencies", None, Some(InputOption::VALUE_NONE), "Alias for --update-with-all-dependencies", None).unwrap().into(),
InputOption::new("ignore-platform-req", None, Some(InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY), "Ignore a specific platform requirement (php & ext- packages).", None).unwrap().into(),
InputOption::new("ignore-platform-reqs", None, Some(InputOption::VALUE_NONE), "Ignore all platform requirements (php & ext- packages).", None).unwrap().into(),
InputOption::new("prefer-stable", None, Some(InputOption::VALUE_NONE), "Prefer stable versions of dependencies (can also be set via the COMPOSER_PREFER_STABLE=1 env var).", None).unwrap().into(),
InputOption::new("prefer-lowest", None, Some(InputOption::VALUE_NONE), "Prefer lowest versions of dependencies (can also be set via the COMPOSER_PREFER_LOWEST=1 env var).", None).unwrap().into(),
- InputOption::new("minimal-changes", Some(PhpMixed::String("m".to_string())), Some(InputOption::VALUE_NONE), "During an update with -w/-W, only perform absolutely necessary changes to transitive dependencies (can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var).", None).unwrap().into(),
+ InputOption::new("minimal-changes", Some("m"), Some(InputOption::VALUE_NONE), "During an update with -w/-W, only perform absolutely necessary changes to transitive dependencies (can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var).", None).unwrap().into(),
InputOption::new("sort-packages", None, Some(InputOption::VALUE_NONE), "Sorts packages when adding/updating a new dependency", None).unwrap().into(),
- InputOption::new("optimize-autoloader", Some(PhpMixed::String("o".to_string())), Some(InputOption::VALUE_NONE), "Optimize autoloader during autoloader dump", None).unwrap().into(),
- InputOption::new("classmap-authoritative", Some(PhpMixed::String("a".to_string())), Some(InputOption::VALUE_NONE), "Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.", None).unwrap().into(),
+ InputOption::new("optimize-autoloader", Some("o"), Some(InputOption::VALUE_NONE), "Optimize autoloader during autoloader dump", None).unwrap().into(),
+ InputOption::new("classmap-authoritative", Some("a"), Some(InputOption::VALUE_NONE), "Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.", None).unwrap().into(),
InputOption::new("apcu-autoloader", None, Some(InputOption::VALUE_NONE), "Use APCu to cache found/not-found classes.", None).unwrap().into(),
InputOption::new("apcu-autoloader-prefix", None, Some(InputOption::VALUE_REQUIRED), "Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader", None).unwrap().into(),
]);
@@ -934,12 +931,8 @@ impl Command for RequireCommand {
let packages: Vec<String> = input
.borrow()
.get_argument("packages")?
- .as_list()
- .map(|l| {
- l.iter()
- .filter_map(|v| v.as_string().map(|s| s.to_string()))
- .collect()
- })
+ .as_array()
+ .map(<[String]>::to_vec)
.unwrap_or_default();
// if there is no update, we need to use the best possible version constraint directly as we cannot rely on the solver to guess the best constraint
let no_update = input
@@ -1057,7 +1050,9 @@ impl Command for RequireCommand {
.to_string(),
true,
) {
- input.borrow_mut().set_option("dev", PhpMixed::Bool(true))?;
+ input
+ .borrow_mut()
+ .set_option("dev", InputValue::Bool(true))?;
}
}
@@ -1142,7 +1137,9 @@ impl Command for RequireCommand {
return Ok(0);
}
- input.borrow_mut().set_option("dev", PhpMixed::Bool(true))?;
+ input
+ .borrow_mut()
+ .set_option("dev", InputValue::Bool(true))?;
std::mem::swap(&mut require_key, &mut remove_key);
}
}
diff --git a/crates/shirabe/src/command/run_script_command.rs b/crates/shirabe/src/command/run_script_command.rs
index a3a7d5be..5dc323cc 100644
--- a/crates/shirabe/src/command/run_script_command.rs
+++ b/crates/shirabe/src/command/run_script_command.rs
@@ -18,6 +18,7 @@ use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::exception::CommandNotFoundException;
use shirabe_symfony_console::exception::NamespaceNotFoundException;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
#[derive(Debug)]
@@ -182,7 +183,7 @@ impl Command for RunScriptCommand {
.into(),
InputOption::new(
"list",
- Some(PhpMixed::String("l".to_string())),
+ Some("l"),
Some(InputOption::VALUE_NONE),
"List scripts.",
None,
@@ -234,7 +235,9 @@ impl Command for RunScriptCommand {
false,
)?;
- input.borrow_mut().set_argument("script", script)?;
+ input
+ .borrow_mut()
+ .set_argument("script", InputValue::from_php_mixed(&script))?;
Ok(())
})();
@@ -309,12 +312,8 @@ impl Command for RunScriptCommand {
let args: Vec<String> = input
.borrow()
.get_argument("args")?
- .as_list()
- .map(|l| {
- l.iter()
- .filter_map(|v| v.as_string().map(|s| s.to_string()))
- .collect()
- })
+ .as_array()
+ .map(<[String]>::to_vec)
.unwrap_or_default();
if let Some(timeout_val) = input.borrow().get_option("timeout")?.as_string() {
diff --git a/crates/shirabe/src/command/script_alias_command.rs b/crates/shirabe/src/command/script_alias_command.rs
index 713947f4..32d32634 100644
--- a/crates/shirabe/src/command/script_alias_command.rs
+++ b/crates/shirabe/src/command/script_alias_command.rs
@@ -144,12 +144,8 @@ impl Command for ScriptAliasCommand {
let args_value: Vec<String> = args
.get("args")
- .and_then(|v| v.as_list())
- .map(|l| {
- l.iter()
- .filter_map(|v| v.as_string().map(|s| s.to_string()))
- .collect()
- })
+ .and_then(|v| v.as_array())
+ .map(<[String]>::to_vec)
.unwrap_or_default();
dispatcher
diff --git a/crates/shirabe/src/command/search_command.rs b/crates/shirabe/src/command/search_command.rs
index e66c574b..0c7e8631 100644
--- a/crates/shirabe/src/command/search_command.rs
+++ b/crates/shirabe/src/command/search_command.rs
@@ -20,6 +20,7 @@ use shirabe_php_shim::{
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::formatter::OutputFormatter;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
#[derive(Debug)]
@@ -54,7 +55,7 @@ impl Command for SearchCommand {
self.set_definition(&[
InputOption::new(
"only-name",
- Some(PhpMixed::String("N".to_string())),
+ Some("N"),
Some(InputOption::VALUE_NONE),
"Search only in package names",
None,
@@ -63,7 +64,7 @@ impl Command for SearchCommand {
.into(),
InputOption::new(
"only-vendor",
- Some(PhpMixed::String("O".to_string())),
+ Some("O"),
Some(InputOption::VALUE_NONE),
"Search only for vendor / organization names, returns only \"vendor\" as result",
None,
@@ -72,7 +73,7 @@ impl Command for SearchCommand {
.into(),
InputOption::new(
"type",
- Some(PhpMixed::String("t".to_string())),
+ Some("t"),
Some(InputOption::VALUE_REQUIRED),
"Search for a specific package type",
None,
@@ -81,10 +82,10 @@ impl Command for SearchCommand {
.into(),
InputOption::new6(
"format",
- Some(PhpMixed::String("f".to_string())),
+ Some("f"),
Some(InputOption::VALUE_REQUIRED),
"Format of the output: text or json",
- Some(PhpMixed::String("text".to_string())),
+ Some(InputValue::String("text".to_string())),
SuggestedValues::List(vec!["json".to_string(), "text".to_string()]),
)
.unwrap()
@@ -204,12 +205,8 @@ impl Command for SearchCommand {
let tokens_arg = input.borrow().get_argument("tokens")?;
let token_strings: Vec<String> = tokens_arg
- .as_list()
- .map(|list| {
- list.iter()
- .filter_map(|v| v.as_string().map(|s| s.to_string()))
- .collect()
- })
+ .as_array()
+ .map(<[String]>::to_vec)
.unwrap_or_default();
let mut query = implode(" ", &token_strings);
if mode != repository_interface::SEARCH_FULLTEXT {
diff --git a/crates/shirabe/src/command/self_update_command.rs b/crates/shirabe/src/command/self_update_command.rs
index dabe8bc8..f78c53af 100644
--- a/crates/shirabe/src/command/self_update_command.rs
+++ b/crates/shirabe/src/command/self_update_command.rs
@@ -7,7 +7,7 @@ use crate::console::input::InputArgument;
use crate::console::input::InputOption;
use crate::io::IOInterfaceImmutable;
use crate::io::io_interface;
-use shirabe_php_shim::{PhpMixed, impl_php_class};
+use shirabe_php_shim::impl_php_class;
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::input::InputInterface;
use shirabe_symfony_console::output::OutputInterface;
@@ -43,7 +43,7 @@ impl Command for SelfUpdateCommand {
self.set_aliases(vec!["selfupdate".to_string()])?;
self.set_description("Updates composer.phar to the latest version");
self.set_definition(&[
- InputOption::new("rollback", Some(PhpMixed::String("r".to_string())), Some(InputOption::VALUE_NONE), "Revert to an older installation of composer", None).unwrap().into(),
+ InputOption::new("rollback", Some("r"), Some(InputOption::VALUE_NONE), "Revert to an older installation of composer", None).unwrap().into(),
InputOption::new("clean-backups", None, Some(InputOption::VALUE_NONE), "Delete old backups during an update. This makes the current version of composer the only backup available after the update", None).unwrap().into(),
InputArgument::new("version", Some(InputArgument::OPTIONAL), "The version to update to", None).unwrap().into(),
InputOption::new("no-progress", None, Some(InputOption::VALUE_NONE), "Do not output download progress.", None).unwrap().into(),
diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs
index 3cc80b4c..f605e2b5 100644
--- a/crates/shirabe/src/command/show_command.rs
+++ b/crates/shirabe/src/command/show_command.rs
@@ -49,6 +49,7 @@ use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::formatter::OutputFormatter;
use shirabe_symfony_console::formatter::OutputFormatterStyle;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
#[derive(Debug)]
@@ -1345,7 +1346,7 @@ impl Command for ShowCommand {
let opt_none = |name: &str, shortcut: Option<&str>, description: &str| {
InputOption::new(
name,
- shortcut.map(|s| PhpMixed::String(s.to_string())),
+ shortcut,
Some(InputOption::VALUE_NONE),
description,
None,
@@ -1432,10 +1433,10 @@ impl Command for ShowCommand {
),
InputOption::new6(
"format",
- Some(PhpMixed::String("f".to_string())),
+ Some("f"),
Some(InputOption::VALUE_REQUIRED),
"Format of the output: text or json",
- Some(PhpMixed::String("text".to_string())),
+ Some(InputValue::String("text".to_string())),
SuggestedValues::List(vec!["json".to_string(), "text".to_string()]),
)
.unwrap()
@@ -1485,7 +1486,7 @@ impl Command for ShowCommand {
if input.borrow().get_option("outdated")?.as_bool() == Some(true) {
input
.borrow_mut()
- .set_option("latest", PhpMixed::Bool(true));
+ .set_option("latest", InputValue::Bool(true));
} else if input
.borrow()
.get_option("ignore")?
@@ -1857,7 +1858,7 @@ impl Command for ShowCommand {
);
input
.borrow_mut()
- .set_option("latest", PhpMixed::Bool(false));
+ .set_option("latest", InputValue::Bool(false));
}
let package_filter: Option<String> = input
@@ -1876,7 +1877,7 @@ impl Command for ShowCommand {
&installed_repo,
&repos,
pf,
- input.borrow().get_argument("version")?,
+ input.borrow().get_argument("version")?.to_php_mixed(),
)?;
if let Some(ref pkg) = matched_package
@@ -2084,7 +2085,9 @@ impl Command for ShowCommand {
self.get_io().write_error(
"No composer.json found in the current directory, disabling \"path\" option",
);
- input.borrow_mut().set_option("path", PhpMixed::Bool(false));
+ input
+ .borrow_mut()
+ .set_option("path", InputValue::Bool(false));
}
for repo in RepositoryUtils::flatten_repositories(repos, true) {
diff --git a/crates/shirabe/src/command/status_command.rs b/crates/shirabe/src/command/status_command.rs
index bcb83a3a..2c7cb361 100644
--- a/crates/shirabe/src/command/status_command.rs
+++ b/crates/shirabe/src/command/status_command.rs
@@ -321,7 +321,7 @@ impl Command for StatusCommand {
self.set_description("Shows a list of locally modified packages");
self.set_definition(&[InputOption::new(
"verbose",
- Some(shirabe_php_shim::PhpMixed::String("v|vv|vvv".to_string())),
+ Some("v|vv|vvv"),
Some(InputOption::VALUE_NONE),
"Show modified files for each directory that contains changes.",
None,
diff --git a/crates/shirabe/src/command/suggests_command.rs b/crates/shirabe/src/command/suggests_command.rs
index 44f903da..e34a1faa 100644
--- a/crates/shirabe/src/command/suggests_command.rs
+++ b/crates/shirabe/src/command/suggests_command.rs
@@ -12,7 +12,7 @@ use crate::repository::RepositoryInterface;
use crate::repository::RepositoryInterfaceHandle;
use crate::repository::RootPackageRepository;
use indexmap::IndexMap;
-use shirabe_php_shim::{PhpMixed, empty, impl_php_class, in_array_loose};
+use shirabe_php_shim::{PhpMixed, impl_php_class, in_array_loose};
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::input::InputInterface;
use shirabe_symfony_console::output::OutputInterface;
@@ -67,7 +67,7 @@ impl Command for SuggestsCommand {
.into(),
InputOption::new(
"all",
- Some(PhpMixed::String("a".to_string())),
+ Some("a"),
Some(InputOption::VALUE_NONE),
"Show suggestions from all dependencies, including transitive ones",
None,
@@ -168,12 +168,18 @@ impl Command for SuggestsCommand {
let mut reporter = SuggestedPackagesReporter::new(self.get_io().clone());
let filter = input.borrow().get_argument("packages")?;
+ let filter_values: Vec<PhpMixed> = filter
+ .as_array()
+ .unwrap_or_default()
+ .iter()
+ .map(|value| PhpMixed::String(value.clone()))
+ .collect();
let mut packages = RepositoryInterface::get_packages(&mut installed_repo)?;
let root_pkg_as_base: crate::package::BasePackageHandle =
composer.get_package().clone().into();
packages.push(root_pkg_as_base);
for package in &packages {
- if !empty(&filter) && !in_array_loose(package.get_name(), filter.values()) {
+ if filter.to_bool() && !in_array_loose(package.get_name(), &filter_values) {
continue;
}
reporter.add_suggestions_from_package(package.clone());
@@ -207,7 +213,7 @@ impl Command for SuggestsCommand {
}
let only_dependents_of: Option<crate::package::PackageInterfaceHandle> =
- if empty(&filter) && !input.borrow().get_option("all")?.as_bool().unwrap_or(false) {
+ if !filter.to_bool() && !input.borrow().get_option("all")?.as_bool().unwrap_or(false) {
Some(composer.get_package().clone().into())
} else {
None
diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs
index d2e380ac..0548fc02 100644
--- a/crates/shirabe/src/command/update_command.rs
+++ b/crates/shirabe/src/command/update_command.rs
@@ -37,6 +37,7 @@ use shirabe_semver::constraint::MultiConstraint;
use shirabe_symfony_console::command::Command;
use shirabe_symfony_console::helper::Table;
use shirabe_symfony_console::input::InputInterface;
+use shirabe_symfony_console::input::InputValue;
use shirabe_symfony_console::output::OutputInterface;
#[derive(Debug)]
@@ -271,27 +272,27 @@ impl Command for UpdateCommand {
InputOption::new("lock", None, Some(InputOption::VALUE_NONE), "Overwrites the lock file hash to suppress warning about the lock file being out of date without updating package versions. Package metadata like mirrors and URLs are updated if they changed.", None).unwrap().into(),
InputOption::new("no-install", None, Some(InputOption::VALUE_NONE), "Skip the install step after updating the composer.lock file.", None).unwrap().into(),
InputOption::new("no-audit", None, Some(InputOption::VALUE_NONE), "Skip the audit step after updating the composer.lock file (can also be set via the COMPOSER_NO_AUDIT=1 env var).", None).unwrap().into(),
- InputOption::new6("audit-format", None, Some(InputOption::VALUE_REQUIRED), "Audit output format. Must be \"table\", \"plain\", \"json\", or \"summary\".", Some(PhpMixed::String(Auditor::FORMAT_SUMMARY.to_string())), SuggestedValues::List(Auditor::FORMATS.iter().map(|s| s.to_string()).collect())).unwrap().into(),
+ InputOption::new6("audit-format", None, Some(InputOption::VALUE_REQUIRED), "Audit output format. Must be \"table\", \"plain\", \"json\", or \"summary\".", Some(InputValue::String(Auditor::FORMAT_SUMMARY.to_string())), SuggestedValues::List(Auditor::FORMATS.iter().map(|s| s.to_string()).collect())).unwrap().into(),
InputOption::new("no-security-blocking", None, Some(InputOption::VALUE_NONE), "Allows installing packages with security advisories or that are abandoned (can also be set via the COMPOSER_NO_SECURITY_BLOCKING=1 env var).", None).unwrap().into(),
InputOption::new("no-autoloader", None, Some(InputOption::VALUE_NONE), "Skips autoloader generation", None).unwrap().into(),
InputOption::new("no-suggest", None, Some(InputOption::VALUE_NONE), "DEPRECATED: This flag does not exist anymore.", None).unwrap().into(),
InputOption::new("no-progress", None, Some(InputOption::VALUE_NONE), "Do not output download progress.", None).unwrap().into(),
- InputOption::new("with-dependencies", Some(PhpMixed::String("w".to_string())), Some(InputOption::VALUE_NONE), "Update also dependencies of packages in the argument list, except those which are root requirements (can also be set via the COMPOSER_WITH_DEPENDENCIES=1 env var).", None).unwrap().into(),
- InputOption::new("with-all-dependencies", Some(PhpMixed::String("W".to_string())), Some(InputOption::VALUE_NONE), "Update also dependencies of packages in the argument list, including those which are root requirements (can also be set via the COMPOSER_WITH_ALL_DEPENDENCIES=1 env var).", None).unwrap().into(),
- InputOption::new("verbose", Some(PhpMixed::String("v|vv|vvv".to_string())), Some(InputOption::VALUE_NONE), "Shows more details including new commits pulled in when updating packages.", None).unwrap().into(),
- InputOption::new("optimize-autoloader", Some(PhpMixed::String("o".to_string())), Some(InputOption::VALUE_NONE), "Optimize autoloader during autoloader dump.", None).unwrap().into(),
- InputOption::new("classmap-authoritative", Some(PhpMixed::String("a".to_string())), Some(InputOption::VALUE_NONE), "Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.", None).unwrap().into(),
+ InputOption::new("with-dependencies", Some("w"), Some(InputOption::VALUE_NONE), "Update also dependencies of packages in the argument list, except those which are root requirements (can also be set via the COMPOSER_WITH_DEPENDENCIES=1 env var).", None).unwrap().into(),
+ InputOption::new("with-all-dependencies", Some("W"), Some(InputOption::VALUE_NONE), "Update also dependencies of packages in the argument list, including those which are root requirements (can also be set via the COMPOSER_WITH_ALL_DEPENDENCIES=1 env var).", None).unwrap().into(),
+ InputOption::new("verbose", Some("v|vv|vvv"), Some(InputOption::VALUE_NONE), "Shows more details including new commits pulled in when updating packages.", None).unwrap().into(),
+ InputOption::new("optimize-autoloader", Some("o"), Some(InputOption::VALUE_NONE), "Optimize autoloader during autoloader dump.", None).unwrap().into(),
+ InputOption::new("classmap-authoritative", Some("a"), Some(InputOption::VALUE_NONE), "Autoload classes from the classmap only. Implicitly enables `--optimize-autoloader`.", None).unwrap().into(),
InputOption::new("apcu-autoloader", None, Some(InputOption::VALUE_NONE), "Use APCu to cache found/not-found classes.", None).unwrap().into(),
InputOption::new("apcu-autoloader-prefix", None, Some(InputOption::VALUE_REQUIRED), "Use a custom prefix for the APCu autoloader cache. Implicitly enables --apcu-autoloader", None).unwrap().into(),
InputOption::new("ignore-platform-req", None, Some(InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY), "Ignore a specific platform requirement (php & ext- packages).", None).unwrap().into(),
InputOption::new("ignore-platform-reqs", None, Some(InputOption::VALUE_NONE), "Ignore all platform requirements (php & ext- packages).", None).unwrap().into(),
InputOption::new("prefer-stable", None, Some(InputOption::VALUE_NONE), "Prefer stable versions of dependencies (can also be set via the COMPOSER_PREFER_STABLE=1 env var).", None).unwrap().into(),
InputOption::new("prefer-lowest", None, Some(InputOption::VALUE_NONE), "Prefer lowest versions of dependencies (can also be set via the COMPOSER_PREFER_LOWEST=1 env var).", None).unwrap().into(),
- InputOption::new("minimal-changes", Some(PhpMixed::String("m".to_string())), Some(InputOption::VALUE_NONE), "Only perform absolutely necessary changes to dependencies. If packages cannot be kept at their currently locked version they are updated. For partial updates the allow-listed packages are always updated fully. (can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var).", None).unwrap().into(),
+ InputOption::new("minimal-changes", Some("m"), Some(InputOption::VALUE_NONE), "Only perform absolutely necessary changes to dependencies. If packages cannot be kept at their currently locked version they are updated. For partial updates the allow-listed packages are always updated fully. (can also be set via the COMPOSER_MINIMAL_CHANGES=1 env var).", None).unwrap().into(),
InputOption::new("patch-only", None, Some(InputOption::VALUE_NONE), "Only allow patch version updates for currently installed dependencies.", None).unwrap().into(),
- InputOption::new("interactive", Some(PhpMixed::String("i".to_string())), Some(InputOption::VALUE_NONE), "Interactive interface with autocompletion to select the packages to update.", None).unwrap().into(),
+ InputOption::new("interactive", Some("i"), Some(InputOption::VALUE_NONE), "Interactive interface with autocompletion to select the packages to update.", None).unwrap().into(),
InputOption::new("root-reqs", None, Some(InputOption::VALUE_NONE), "Restricts the update to your first degree dependencies.", None).unwrap().into(),
- InputOption::new6("bump-after-update", None, Some(InputOption::VALUE_OPTIONAL), "Runs bump after performing the update.", Some(PhpMixed::Bool(false)), crate::console::input::SuggestedValues::List(vec!["dev".to_string(), "no-dev".to_string(), "all".to_string()])).unwrap().into(),
+ InputOption::new6("bump-after-update", None, Some(InputOption::VALUE_OPTIONAL), "Runs bump after performing the update.", Some(InputValue::Bool(false)), crate::console::input::SuggestedValues::List(vec!["dev".to_string(), "no-dev".to_string(), "all".to_string()])).unwrap().into(),
]);
self.set_help(
"The <info>update</info> command reads the composer.json file from the\n\
@@ -354,12 +355,8 @@ impl Command for UpdateCommand {
let mut packages: Vec<String> = input
.borrow()
.get_argument("packages")?
- .as_list()
- .map(|l| {
- l.iter()
- .filter_map(|v| v.as_string().map(|s| s.to_string()))
- .collect()
- })
+ .as_array()
+ .map(<[String]>::to_vec)
.unwrap_or_default();
let mut reqs: IndexMap<String, String> = self.format_requirements(
input
@@ -731,12 +728,8 @@ impl Command for UpdateCommand {
input
.borrow()
.get_argument("packages")?
- .as_list()
- .map(|l| {
- l.iter()
- .filter_map(|v| v.as_string().map(|s| s.to_string()))
- .collect()
- })
+ .as_array()
+ .map(<[String]>::to_vec)
.unwrap_or_default(),
"--bump-after-update=dev".to_string(),
)?;
diff --git a/crates/shirabe/src/command/validate_command.rs b/crates/shirabe/src/command/validate_command.rs
index d2e8f2a7..d460ea6c 100644
--- a/crates/shirabe/src/command/validate_command.rs
+++ b/crates/shirabe/src/command/validate_command.rs
@@ -189,7 +189,7 @@ impl Command for ValidateCommand {
.into(),
InputOption::new(
"with-dependencies",
- Some(shirabe_php_shim::PhpMixed::String("A".to_string())),
+ Some("A"),
Some(InputOption::VALUE_NONE),
"Also validate the composer.json of all installed dependencies",
None,