aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/src/command
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-06-29 00:03:00 +0900
committernsfisis <nsfisis@gmail.com>2026-06-29 00:03:00 +0900
commit9be0f98f71fe8071ab839ac1036b4064ac3172b4 (patch)
tree66a2f4feba752f4761c40449e0827ad74fc9b02c /crates/shirabe/src/command
parenta84d531548efa678d4021cea891826e59f8fb462 (diff)
downloadphp-shirabe-9be0f98f71fe8071ab839ac1036b4064ac3172b4.tar.gz
php-shirabe-9be0f98f71fe8071ab839ac1036b4064ac3172b4.tar.zst
php-shirabe-9be0f98f71fe8071ab839ac1036b4064ac3172b4.zip
chore(lint): ban bare `use anyhow::Result` and fully qualify it
Add a no_banned_use linter that forbids importing anyhow::Result, and update all call sites to reference it via its fully-qualified path so it is never confused with std::result::Result. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command')
-rw-r--r--crates/shirabe/src/command/about_command.rs1
-rw-r--r--crates/shirabe/src/command/archive_command.rs5
-rw-r--r--crates/shirabe/src/command/audit_command.rs3
-rw-r--r--crates/shirabe/src/command/base_command.rs45
-rw-r--r--crates/shirabe/src/command/bump_command.rs5
-rw-r--r--crates/shirabe/src/command/check_platform_reqs_command.rs1
-rw-r--r--crates/shirabe/src/command/clear_cache_command.rs1
-rw-r--r--crates/shirabe/src/command/config_command.rs1
-rw-r--r--crates/shirabe/src/command/create_project_command.rs5
-rw-r--r--crates/shirabe/src/command/depends_command.rs1
-rw-r--r--crates/shirabe/src/command/diagnose_command.rs3
-rw-r--r--crates/shirabe/src/command/dump_autoload_command.rs1
-rw-r--r--crates/shirabe/src/command/exec_command.rs3
-rw-r--r--crates/shirabe/src/command/fund_command.rs3
-rw-r--r--crates/shirabe/src/command/global_command.rs5
-rw-r--r--crates/shirabe/src/command/home_command.rs5
-rw-r--r--crates/shirabe/src/command/init_command.rs21
-rw-r--r--crates/shirabe/src/command/install_command.rs1
-rw-r--r--crates/shirabe/src/command/licenses_command.rs1
-rw-r--r--crates/shirabe/src/command/outdated_command.rs1
-rw-r--r--crates/shirabe/src/command/package_discovery_trait.rs11
-rw-r--r--crates/shirabe/src/command/prohibits_command.rs1
-rw-r--r--crates/shirabe/src/command/reinstall_command.rs1
-rw-r--r--crates/shirabe/src/command/remove_command.rs1
-rw-r--r--crates/shirabe/src/command/repository_command.rs1
-rw-r--r--crates/shirabe/src/command/require_command.rs7
-rw-r--r--crates/shirabe/src/command/run_script_command.rs5
-rw-r--r--crates/shirabe/src/command/script_alias_command.rs7
-rw-r--r--crates/shirabe/src/command/search_command.rs1
-rw-r--r--crates/shirabe/src/command/self_update_command.rs1
-rw-r--r--crates/shirabe/src/command/show_command.rs1
-rw-r--r--crates/shirabe/src/command/status_command.rs3
-rw-r--r--crates/shirabe/src/command/suggests_command.rs3
-rw-r--r--crates/shirabe/src/command/update_command.rs8
-rw-r--r--crates/shirabe/src/command/validate_command.rs1
35 files changed, 78 insertions, 86 deletions
diff --git a/crates/shirabe/src/command/about_command.rs b/crates/shirabe/src/command/about_command.rs
index 94c877a..7983a58 100644
--- a/crates/shirabe/src/command/about_command.rs
+++ b/crates/shirabe/src/command/about_command.rs
@@ -4,7 +4,6 @@ use crate::command::BaseCommand;
use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
use crate::composer;
-use anyhow::Result;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
diff --git a/crates/shirabe/src/command/archive_command.rs b/crates/shirabe/src/command/archive_command.rs
index ce1d496..741847a 100644
--- a/crates/shirabe/src/command/archive_command.rs
+++ b/crates/shirabe/src/command/archive_command.rs
@@ -22,7 +22,6 @@ use crate::util::Filesystem;
use crate::util::Platform;
use crate::util::ProcessExecutor;
use crate::util::r#loop::Loop;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::symfony::console::command::command::Command;
@@ -260,7 +259,7 @@ impl ArchiveCommand {
file_name: Option<String>,
ignore_filters: bool,
composer: Option<&PartialComposerHandle>,
- ) -> Result<i64> {
+ ) -> anyhow::Result<i64> {
let archive_stub_return = self.test_hooks.borrow().archive_stub_return;
if let Some(return_value) = archive_stub_return {
self.test_hooks
@@ -352,7 +351,7 @@ impl ArchiveCommand {
io: std::rc::Rc<std::cell::RefCell<dyn IOInterface>>,
package_name: &str,
version: Option<&str>,
- ) -> Result<Option<crate::package::CompletePackageInterfaceHandle>> {
+ ) -> anyhow::Result<Option<crate::package::CompletePackageInterfaceHandle>> {
io.write_error("<info>Searching for the specified package.</info>");
let mut version = version.map(|v| v.to_string());
diff --git a/crates/shirabe/src/command/audit_command.rs b/crates/shirabe/src/command/audit_command.rs
index 59d11a6..24af44c 100644
--- a/crates/shirabe/src/command/audit_command.rs
+++ b/crates/shirabe/src/command/audit_command.rs
@@ -11,7 +11,6 @@ use crate::io::IOInterfaceImmutable;
use crate::repository::CanonicalPackagesTrait;
use crate::repository::RepositorySet;
use crate::repository::RepositoryUtils;
-use anyhow::Result;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
@@ -243,7 +242,7 @@ impl AuditCommand {
&self,
composer: &PartialComposerHandle,
input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
- ) -> Result<Vec<crate::package::PackageInterfaceHandle>> {
+ ) -> anyhow::Result<Vec<crate::package::PackageInterfaceHandle>> {
let composer = crate::composer::composer_full(composer);
if input
.borrow()
diff --git a/crates/shirabe/src/command/base_command.rs b/crates/shirabe/src/command/base_command.rs
index 46ee5f7..25618c5 100644
--- a/crates/shirabe/src/command/base_command.rs
+++ b/crates/shirabe/src/command/base_command.rs
@@ -17,7 +17,6 @@ use crate::package::version::VersionParser;
use crate::plugin::PluginEvents;
use crate::plugin::PreCommandRunEvent;
use crate::util::Platform;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::symfony::console::Terminal;
use shirabe_external_packages::symfony::console::command::command::{
@@ -139,7 +138,7 @@ pub trait BaseCommand: Command {
&self,
disable_plugins: Option<bool>,
disable_scripts: Option<bool>,
- ) -> Result<PartialComposerHandle>;
+ ) -> anyhow::Result<PartialComposerHandle>;
/// Retrieves the default Composer\Composer instance or null
fn try_composer(
@@ -151,7 +150,7 @@ pub trait BaseCommand: Command {
fn set_composer(&self, composer: PartialComposerHandle);
/// Removes the cached composer instance
- fn reset_composer(&self) -> Result<()>;
+ fn reset_composer(&self) -> anyhow::Result<()>;
fn get_io(&self) -> Rc<RefCell<dyn IOInterface>>;
@@ -165,7 +164,7 @@ pub trait BaseCommand: Command {
config: Option<IndexMap<String, PhpMixed>>,
disable_plugins: bool,
disable_scripts: Option<bool>,
- ) -> Result<PartialComposerHandle>;
+ ) -> anyhow::Result<PartialComposerHandle>;
/// Returns preferSource and preferDist values based on the configuration.
fn get_preferred_install_options(
@@ -173,17 +172,20 @@ pub trait BaseCommand: Command {
config: &Config,
input: Rc<RefCell<dyn InputInterface>>,
keep_vcs_requires_prefer_source: bool,
- ) -> Result<(bool, bool)>;
+ ) -> anyhow::Result<(bool, bool)>;
fn get_platform_requirement_filter(
&self,
input: Rc<RefCell<dyn InputInterface>>,
- ) -> Result<Rc<dyn PlatformRequirementFilterInterface>>;
+ ) -> anyhow::Result<Rc<dyn PlatformRequirementFilterInterface>>;
/// @param array<string> $requirements
///
/// @return array<string, string>
- fn format_requirements(&self, requirements: Vec<String>) -> Result<IndexMap<String, String>>;
+ fn format_requirements(
+ &self,
+ requirements: Vec<String>,
+ ) -> anyhow::Result<IndexMap<String, String>>;
/// @param array<string> $requirements
///
@@ -191,7 +193,7 @@ pub trait BaseCommand: Command {
fn normalize_requirements(
&self,
requirements: Vec<String>,
- ) -> Result<Vec<IndexMap<String, String>>>;
+ ) -> anyhow::Result<Vec<IndexMap<String, String>>>;
/// @param array<TableSeparator|mixed[]> $table
fn render_table(&self, table: Vec<PhpMixed>, output: Rc<RefCell<dyn OutputInterface>>);
@@ -205,14 +207,14 @@ pub trait BaseCommand: Command {
&self,
input: Rc<RefCell<dyn InputInterface>>,
opt_name: &str,
- ) -> Result<String>;
+ ) -> anyhow::Result<String>;
/// Creates an AuditConfig from the Config object, optionally overriding security blocking based on input options
fn create_audit_config(
&self,
config: &mut Config,
input: Rc<RefCell<dyn InputInterface>>,
- ) -> Result<AuditConfig>;
+ ) -> anyhow::Result<AuditConfig>;
}
/// Forwards every Composer-specific `BaseCommand` method that no command overrides to an
@@ -253,7 +255,7 @@ impl BaseCommand for BaseCommandData {
&self,
disable_plugins: Option<bool>,
disable_scripts: Option<bool>,
- ) -> Result<PartialComposerHandle> {
+ ) -> anyhow::Result<PartialComposerHandle> {
if self.composer.borrow().is_none() {
let application = self.get_application();
let Some(application) = application else {
@@ -311,7 +313,7 @@ impl BaseCommand for BaseCommandData {
*self.composer.borrow_mut() = Some(composer);
}
- fn reset_composer(&self) -> Result<()> {
+ fn reset_composer(&self) -> anyhow::Result<()> {
*self.composer.borrow_mut() = None;
if let Some(application) = self.get_application() {
let mut app_ref = application.borrow_mut();
@@ -360,7 +362,7 @@ impl BaseCommand for BaseCommandData {
config: Option<IndexMap<String, PhpMixed>>,
disable_plugins: bool,
disable_scripts: Option<bool>,
- ) -> Result<PartialComposerHandle> {
+ ) -> anyhow::Result<PartialComposerHandle> {
let disable_plugins = disable_plugins
|| input
.borrow()
@@ -388,7 +390,7 @@ impl BaseCommand for BaseCommandData {
config: &Config,
input: Rc<RefCell<dyn InputInterface>>,
keep_vcs_requires_prefer_source: bool,
- ) -> Result<(bool, bool)> {
+ ) -> anyhow::Result<(bool, bool)> {
let mut prefer_source = false;
let mut prefer_dist = false;
@@ -510,7 +512,7 @@ impl BaseCommand for BaseCommandData {
fn get_platform_requirement_filter(
&self,
input: Rc<RefCell<dyn InputInterface>>,
- ) -> Result<Rc<dyn PlatformRequirementFilterInterface>> {
+ ) -> anyhow::Result<Rc<dyn PlatformRequirementFilterInterface>> {
if !input.borrow().has_option("ignore-platform-reqs")
|| !input.borrow().has_option("ignore-platform-req")
{
@@ -540,7 +542,10 @@ impl BaseCommand for BaseCommandData {
Ok(PlatformRequirementFilterFactory::ignore_nothing())
}
- fn format_requirements(&self, requirements: Vec<String>) -> Result<IndexMap<String, String>> {
+ fn format_requirements(
+ &self,
+ requirements: Vec<String>,
+ ) -> anyhow::Result<IndexMap<String, String>> {
let mut requires: IndexMap<String, String> = IndexMap::new();
let requirements = self.normalize_requirements(requirements)?;
for requirement in requirements {
@@ -567,7 +572,7 @@ impl BaseCommand for BaseCommandData {
fn normalize_requirements(
&self,
requirements: Vec<String>,
- ) -> Result<Vec<IndexMap<String, String>>> {
+ ) -> anyhow::Result<Vec<IndexMap<String, String>>> {
let parser: VersionParser = VersionParser::new();
parser.parse_name_version_pairs(requirements)
@@ -602,7 +607,7 @@ impl BaseCommand for BaseCommandData {
&self,
input: Rc<RefCell<dyn InputInterface>>,
opt_name: &str,
- ) -> Result<String> {
+ ) -> anyhow::Result<String> {
if !input.borrow().has_option(opt_name) {
return Err(LogicException {
message: format!(
@@ -638,7 +643,7 @@ impl BaseCommand for BaseCommandData {
&self,
config: &mut Config,
input: Rc<RefCell<dyn InputInterface>>,
- ) -> Result<AuditConfig> {
+ ) -> anyhow::Result<AuditConfig> {
// Handle both --audit and --no-audit flags
let audit = if input.borrow().has_option("audit") {
input
@@ -700,7 +705,7 @@ pub fn base_command_initialize(
cmd: &dyn BaseCommand,
input: Rc<RefCell<dyn InputInterface>>,
_output: Rc<RefCell<dyn OutputInterface>>,
-) -> Result<()> {
+) -> anyhow::Result<()> {
// initialize a plugin-enabled Composer instance, either local or global
// PHP also ORs in $this->getApplication()->getDisablePluginsByDefault() /
// getDisableScriptsByDefault().
diff --git a/crates/shirabe/src/command/bump_command.rs b/crates/shirabe/src/command/bump_command.rs
index 79fedfb..e3dac8a 100644
--- a/crates/shirabe/src/command/bump_command.rs
+++ b/crates/shirabe/src/command/bump_command.rs
@@ -15,7 +15,6 @@ use crate::package::version::VersionBumper;
use crate::repository::PlatformRepository;
use crate::util::Filesystem;
use crate::util::Silencer;
-use anyhow::Result;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
@@ -57,7 +56,7 @@ impl BumpCommand {
dry_run: bool,
packages_filter: Vec<String>,
dev_only_flag_hint: String,
- ) -> Result<i64> {
+ ) -> anyhow::Result<i64> {
let composer_json_path = Factory::get_composer_file()?;
if !Filesystem::is_readable(&composer_json_path) {
@@ -298,7 +297,7 @@ impl BumpCommand {
&self,
json: &JsonFile,
updates: &indexmap::IndexMap<&str, indexmap::IndexMap<String, String>>,
- ) -> Result<bool> {
+ ) -> anyhow::Result<bool> {
let contents = match file_get_contents(json.get_path()) {
Some(c) => c,
None => {
diff --git a/crates/shirabe/src/command/check_platform_reqs_command.rs b/crates/shirabe/src/command/check_platform_reqs_command.rs
index 4b4e043..4f53e79 100644
--- a/crates/shirabe/src/command/check_platform_reqs_command.rs
+++ b/crates/shirabe/src/command/check_platform_reqs_command.rs
@@ -10,7 +10,6 @@ use crate::repository::InstalledRepository;
use crate::repository::PlatformRepository;
use crate::repository::RepositoryInterface;
use crate::repository::RootPackageRepository;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
diff --git a/crates/shirabe/src/command/clear_cache_command.rs b/crates/shirabe/src/command/clear_cache_command.rs
index 696b1dc..2e41412 100644
--- a/crates/shirabe/src/command/clear_cache_command.rs
+++ b/crates/shirabe/src/command/clear_cache_command.rs
@@ -8,7 +8,6 @@ use crate::config::Config;
use crate::console::input::InputOption;
use crate::factory::Factory;
use crate::io::IOInterfaceImmutable;
-use anyhow::Result;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
diff --git a/crates/shirabe/src/command/config_command.rs b/crates/shirabe/src/command/config_command.rs
index e1ebf1a..6c2e777 100644
--- a/crates/shirabe/src/command/config_command.rs
+++ b/crates/shirabe/src/command/config_command.rs
@@ -16,7 +16,6 @@ use crate::package::base_package::{self};
use crate::util::Filesystem;
use crate::util::Platform;
use crate::util::Silencer;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::symfony::console::command::command::Command;
diff --git a/crates/shirabe/src/command/create_project_command.rs b/crates/shirabe/src/command/create_project_command.rs
index 8f01f98..e63502a 100644
--- a/crates/shirabe/src/command/create_project_command.rs
+++ b/crates/shirabe/src/command/create_project_command.rs
@@ -32,7 +32,6 @@ use crate::script::ScriptEvents;
use crate::util::Filesystem;
use crate::util::Platform;
use crate::util::ProcessExecutor;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::seld::signal::SignalHandler;
@@ -302,7 +301,7 @@ impl CreateProjectCommand {
platform_requirement_filter: Option<std::rc::Rc<dyn PlatformRequirementFilterInterface>>,
secure_http: bool,
add_repository: bool,
- ) -> Result<i64> {
+ ) -> anyhow::Result<i64> {
let old_cwd = Platform::get_cwd(false)?;
let repositories: Option<Vec<String>> = match repositories {
@@ -648,7 +647,7 @@ impl CreateProjectCommand {
disable_scripts: bool,
no_progress: bool,
secure_http: bool,
- ) -> Result<bool> {
+ ) -> anyhow::Result<bool> {
let parser: VersionParser = VersionParser::new();
let requirements = parser.parse_name_version_pairs(vec![package_name.to_string()])?;
let name = strtolower(
diff --git a/crates/shirabe/src/command/depends_command.rs b/crates/shirabe/src/command/depends_command.rs
index 39e916a..00b5abc 100644
--- a/crates/shirabe/src/command/depends_command.rs
+++ b/crates/shirabe/src/command/depends_command.rs
@@ -6,7 +6,6 @@ use crate::command::BaseDependencyCommand;
use crate::command::base_command::base_command_initialize;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use anyhow::Result;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
diff --git a/crates/shirabe/src/command/diagnose_command.rs b/crates/shirabe/src/command/diagnose_command.rs
index 656f730..a465182 100644
--- a/crates/shirabe/src/command/diagnose_command.rs
+++ b/crates/shirabe/src/command/diagnose_command.rs
@@ -32,7 +32,6 @@ use crate::util::Platform;
use crate::util::ProcessExecutor;
use crate::util::http::ProxyManager;
use crate::util::http::RequestProxy;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::composer::xdebug_handler::XdebugHandler;
@@ -347,7 +346,7 @@ impl Command for DiagnoseCommand {
} else {
vec!["http", "https"]
};
- let proxy_check_result: Result<(), anyhow::Error> = (|| -> anyhow::Result<()> {
+ let proxy_check_result: anyhow::Result<(), anyhow::Error> = (|| -> anyhow::Result<()> {
for proto in &protos {
let proxy = proxy_manager
.lock()
diff --git a/crates/shirabe/src/command/dump_autoload_command.rs b/crates/shirabe/src/command/dump_autoload_command.rs
index baae79d..de917b5 100644
--- a/crates/shirabe/src/command/dump_autoload_command.rs
+++ b/crates/shirabe/src/command/dump_autoload_command.rs
@@ -7,7 +7,6 @@ use crate::console::input::InputOption;
use crate::io::IOInterfaceImmutable;
use crate::plugin::CommandEvent;
use crate::plugin::PluginEvents;
-use anyhow::Result;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
diff --git a/crates/shirabe/src/command/exec_command.rs b/crates/shirabe/src/command/exec_command.rs
index 8b7d5f7..a394ac4 100644
--- a/crates/shirabe/src/command/exec_command.rs
+++ b/crates/shirabe/src/command/exec_command.rs
@@ -6,7 +6,6 @@ use crate::command::base_command::base_command_initialize;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
use crate::io::IOInterfaceImmutable;
-use anyhow::Result;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
@@ -36,7 +35,7 @@ impl ExecCommand {
command
}
- fn get_binaries(&self, for_display: bool) -> Result<Vec<String>> {
+ fn get_binaries(&self, for_display: bool) -> anyhow::Result<Vec<String>> {
let composer = self.require_composer(None, None)?;
let composer_ref = crate::composer::composer_full(&composer);
let bin_dir = composer_ref
diff --git a/crates/shirabe/src/command/fund_command.rs b/crates/shirabe/src/command/fund_command.rs
index ad4f94f..5d1dfea 100644
--- a/crates/shirabe/src/command/fund_command.rs
+++ b/crates/shirabe/src/command/fund_command.rs
@@ -8,7 +8,6 @@ use crate::json::JsonFile;
use crate::package::base_package::{self};
use crate::repository::CompositeRepository;
use crate::repository::RepositoryInterface;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::console::command::command::Command;
@@ -46,7 +45,7 @@ impl FundCommand {
fn insert_funding_data(
fundings: &mut IndexMap<String, IndexMap<String, Vec<String>>>,
package: &crate::package::CompletePackageInterfaceHandle,
- ) -> Result<()> {
+ ) -> anyhow::Result<()> {
let pretty_name = package.get_pretty_name();
let (vendor, package_name) = pretty_name
.split_once('/')
diff --git a/crates/shirabe/src/command/global_command.rs b/crates/shirabe/src/command/global_command.rs
index 04c2409..5769ebb 100644
--- a/crates/shirabe/src/command/global_command.rs
+++ b/crates/shirabe/src/command/global_command.rs
@@ -7,7 +7,6 @@ use crate::console::input::InputArgument;
use crate::factory::Factory;
use crate::util::Filesystem;
use crate::util::Platform;
-use anyhow::Result;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::ArgvInput;
@@ -48,7 +47,7 @@ impl GlobalCommand {
// Mirrors PHP's `method_exists($input, '__toString')` guard followed by
// `$input->__toString()`. `InputInterface` does not declare `__toString`, so the
// concrete stringable input types are matched explicitly.
- fn input_to_string(input: &dyn InputInterface) -> Result<String> {
+ fn input_to_string(input: &dyn InputInterface) -> anyhow::Result<String> {
let input_any = input.as_any();
if let Some(argv_input) = input_any.downcast_ref::<ArgvInput>() {
Ok(argv_input.to_string())
@@ -71,7 +70,7 @@ impl GlobalCommand {
&self,
input: Rc<RefCell<dyn InputInterface>>,
quiet: bool,
- ) -> Result<StringInput> {
+ ) -> anyhow::Result<StringInput> {
if Platform::get_env("COMPOSER").is_some() {
Platform::clear_env("COMPOSER");
}
diff --git a/crates/shirabe/src/command/home_command.rs b/crates/shirabe/src/command/home_command.rs
index 682cb6a..8ff43f3 100644
--- a/crates/shirabe/src/command/home_command.rs
+++ b/crates/shirabe/src/command/home_command.rs
@@ -11,7 +11,6 @@ use crate::repository::RepositoryFactory;
use crate::repository::RootPackageRepository;
use crate::util::Platform;
use crate::util::ProcessExecutor;
-use anyhow::Result;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
@@ -106,7 +105,9 @@ impl HomeCommand {
}
}
- fn initialize_repos(&self) -> Result<Vec<crate::repository::RepositoryInterfaceHandle>> {
+ fn initialize_repos(
+ &self,
+ ) -> anyhow::Result<Vec<crate::repository::RepositoryInterfaceHandle>> {
let composer = self.try_composer(None, None);
if let Some(composer) = composer {
diff --git a/crates/shirabe/src/command/init_command.rs b/crates/shirabe/src/command/init_command.rs
index dc91069..856cc78 100644
--- a/crates/shirabe/src/command/init_command.rs
+++ b/crates/shirabe/src/command/init_command.rs
@@ -17,7 +17,6 @@ use crate::repository::RepositoryFactory;
use crate::util::Filesystem;
use crate::util::ProcessExecutor;
use crate::util::Silencer;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::symfony::console::command::command::Command;
@@ -918,7 +917,10 @@ impl BaseCommand for InitCommand {
impl InitCommand {
/// @return array{name: string, email: string|null}
- fn parse_author_string(&self, author: &str) -> Result<IndexMap<String, Option<String>>> {
+ fn parse_author_string(
+ &self,
+ author: &str,
+ ) -> anyhow::Result<IndexMap<String, Option<String>>> {
let mut m: IndexMap<CaptureKey, String> = IndexMap::new();
if Preg::is_match3(
r#"/^(?P<name>[- .,\p{L}\p{N}\p{Mn}\'’\"()]+)(?:\s+<(?P<email>.+?)>)?$/u"#,
@@ -960,7 +962,10 @@ impl InitCommand {
}
/// @return array<int, array{name: string, email?: string}>
- pub(crate) fn format_authors(&self, author: &str) -> Result<Vec<IndexMap<String, PhpMixed>>> {
+ pub(crate) fn format_authors(
+ &self,
+ author: &str,
+ ) -> anyhow::Result<Vec<IndexMap<String, PhpMixed>>> {
let parsed = self.parse_author_string(author)?;
let mut author_map: IndexMap<String, PhpMixed> = IndexMap::new();
let name = parsed.get("name").cloned().unwrap_or(None);
@@ -1072,12 +1077,18 @@ impl InitCommand {
}
/// For testing only: invoke the private `parse_author_string`.
- pub fn __parse_author_string(&self, author: &str) -> Result<IndexMap<String, Option<String>>> {
+ pub fn __parse_author_string(
+ &self,
+ author: &str,
+ ) -> anyhow::Result<IndexMap<String, Option<String>>> {
self.parse_author_string(author)
}
/// For testing only: invoke the crate-private `format_authors`.
- pub fn __format_authors(&self, author: &str) -> Result<Vec<IndexMap<String, PhpMixed>>> {
+ pub fn __format_authors(
+ &self,
+ author: &str,
+ ) -> anyhow::Result<Vec<IndexMap<String, PhpMixed>>> {
self.format_authors(author)
}
diff --git a/crates/shirabe/src/command/install_command.rs b/crates/shirabe/src/command/install_command.rs
index 2f782cc..1192968 100644
--- a/crates/shirabe/src/command/install_command.rs
+++ b/crates/shirabe/src/command/install_command.rs
@@ -11,7 +11,6 @@ use crate::io::IOInterfaceImmutable;
use crate::plugin::CommandEvent;
use crate::plugin::PluginEvents;
use crate::util::HttpDownloader;
-use anyhow::Result;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
diff --git a/crates/shirabe/src/command/licenses_command.rs b/crates/shirabe/src/command/licenses_command.rs
index c5cdf2a..52f7d2f 100644
--- a/crates/shirabe/src/command/licenses_command.rs
+++ b/crates/shirabe/src/command/licenses_command.rs
@@ -11,7 +11,6 @@ use crate::repository::RepositoryInterface;
use crate::repository::RepositoryUtils;
use crate::util::PackageInfo;
use crate::util::PackageSorter;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::formatter::OutputFormatter;
diff --git a/crates/shirabe/src/command/outdated_command.rs b/crates/shirabe/src/command/outdated_command.rs
index be921e1..73f191d 100644
--- a/crates/shirabe/src/command/outdated_command.rs
+++ b/crates/shirabe/src/command/outdated_command.rs
@@ -5,7 +5,6 @@ use crate::command::BaseCommandData;
use crate::command::base_command::base_command_initialize;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::ArrayInput;
diff --git a/crates/shirabe/src/command/package_discovery_trait.rs b/crates/shirabe/src/command/package_discovery_trait.rs
index c3f744c..475b67d 100644
--- a/crates/shirabe/src/command/package_discovery_trait.rs
+++ b/crates/shirabe/src/command/package_discovery_trait.rs
@@ -17,7 +17,6 @@ use crate::repository::RepositoryFactory;
use crate::repository::RepositorySet;
use crate::repository::{RepositoryInterface, SearchResult};
use crate::util::Filesystem;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::symfony::console::input::InputInterface;
@@ -104,7 +103,7 @@ pub trait PackageDiscoveryTrait: BaseCommand {
&input
.borrow()
.get_option("stability")
- .expect("get_minimum_stability returns String, not Result; stability option is guaranteed present by the has_option guard above")
+ .expect("get_minimum_stability returns String, not anyhow::Result; stability option is guaranteed present by the has_option guard above")
.as_string()
.map(|s| s.to_string())
.unwrap_or_else(|| "stable".to_string()),
@@ -139,7 +138,7 @@ pub trait PackageDiscoveryTrait: BaseCommand {
preferred_stability: &str,
use_best_version_constraint: bool,
fixed: bool,
- ) -> Result<Vec<String>> {
+ ) -> anyhow::Result<Vec<String>> {
if !requires.is_empty() {
let requires_norm = self.normalize_requirements(requires.clone())?;
let mut result: Vec<String> = vec![];
@@ -462,7 +461,7 @@ pub trait PackageDiscoveryTrait: BaseCommand {
platform_repo: Option<&PlatformRepositoryHandle>,
preferred_stability: &str,
fixed: bool,
- ) -> Result<(String, String)> {
+ ) -> anyhow::Result<(String, String)> {
// handle ignore-platform-reqs flag if present
let platform_requirement_filter = if input.borrow().has_option("ignore-platform-reqs")
&& input.borrow().has_option("ignore-platform-req")
@@ -751,8 +750,8 @@ pub trait PackageDiscoveryTrait: BaseCommand {
}
/// @return array<string>
- fn find_similar(&self, package: &str) -> Result<Vec<String>> {
- let results: Vec<SearchResult> = match (|| -> Result<Vec<SearchResult>> {
+ fn find_similar(&self, package: &str) -> anyhow::Result<Vec<String>> {
+ let results: Vec<SearchResult> = match (|| -> anyhow::Result<Vec<SearchResult>> {
if self.get_repos_mut().is_none() {
return Err(LogicException {
message: "findSimilar was called before $this->repos was initialized"
diff --git a/crates/shirabe/src/command/prohibits_command.rs b/crates/shirabe/src/command/prohibits_command.rs
index 2423dc7..9f9b0ee 100644
--- a/crates/shirabe/src/command/prohibits_command.rs
+++ b/crates/shirabe/src/command/prohibits_command.rs
@@ -5,7 +5,6 @@ use crate::command::base_command::base_command_initialize;
use crate::command::{BaseCommand, BaseCommandData};
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
-use anyhow::Result;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
diff --git a/crates/shirabe/src/command/reinstall_command.rs b/crates/shirabe/src/command/reinstall_command.rs
index 2cafbc3..3fddf1f 100644
--- a/crates/shirabe/src/command/reinstall_command.rs
+++ b/crates/shirabe/src/command/reinstall_command.rs
@@ -14,7 +14,6 @@ use crate::plugin::CommandEvent;
use crate::plugin::PluginEvents;
use crate::script::ScriptEvents;
use crate::util::Platform;
-use anyhow::Result;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
diff --git a/crates/shirabe/src/command/remove_command.rs b/crates/shirabe/src/command/remove_command.rs
index 7422151..aa8f772 100644
--- a/crates/shirabe/src/command/remove_command.rs
+++ b/crates/shirabe/src/command/remove_command.rs
@@ -14,7 +14,6 @@ use crate::io::IOInterfaceImmutable;
use crate::json::JsonFile;
use crate::package::base_package;
use crate::repository::RepositoryInterface;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::console::command::command::Command;
diff --git a/crates/shirabe/src/command/repository_command.rs b/crates/shirabe/src/command/repository_command.rs
index ba0778c..89fb84b 100644
--- a/crates/shirabe/src/command/repository_command.rs
+++ b/crates/shirabe/src/command/repository_command.rs
@@ -9,7 +9,6 @@ use crate::console::input::InputArgument;
use crate::console::input::InputOption;
use crate::io::IOInterfaceImmutable;
use crate::json::JsonFile;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::console::command::command::Command;
diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs
index ebd090a..6a3ff5e 100644
--- a/crates/shirabe/src/command/require_command.rs
+++ b/crates/shirabe/src/command/require_command.rs
@@ -29,7 +29,6 @@ use crate::repository::RepositorySet;
use crate::util::Filesystem;
use crate::util::PackageSorter;
use crate::util::Silencer;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::seld::signal::SignalHandler;
@@ -163,7 +162,7 @@ impl Command for RequireCommand {
&self,
input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
- ) -> Result<i64> {
+ ) -> anyhow::Result<i64> {
*self.file.borrow_mut() = Factory::get_composer_file()?;
if input
@@ -748,7 +747,7 @@ impl RequireCommand {
requirements: &IndexMap<String, String>,
require_key: &str,
_remove_key: &str,
- ) -> Result<i64> {
+ ) -> anyhow::Result<i64> {
// Update packages
self.reset_composer()?;
let composer_handle = self.require_composer(None, None)?;
@@ -1053,7 +1052,7 @@ impl RequireCommand {
sort_packages: bool,
dry_run: bool,
fixed: bool,
- ) -> Result<i64> {
+ ) -> anyhow::Result<i64> {
let composer = self.require_composer(None, None)?;
let composer = crate::composer::composer_full(&composer);
let locker_is_locked = composer.get_locker().borrow_mut().is_locked();
diff --git a/crates/shirabe/src/command/run_script_command.rs b/crates/shirabe/src/command/run_script_command.rs
index 869d97b..fdfc4c0 100644
--- a/crates/shirabe/src/command/run_script_command.rs
+++ b/crates/shirabe/src/command/run_script_command.rs
@@ -10,7 +10,6 @@ use crate::script::Event as ScriptEvent;
use crate::script::ScriptEvents;
use crate::util::Platform;
use crate::util::ProcessExecutor;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
@@ -58,7 +57,7 @@ impl RunScriptCommand {
command
}
- fn list_scripts(&self, output: Rc<RefCell<dyn OutputInterface>>) -> Result<i64> {
+ fn list_scripts(&self, output: Rc<RefCell<dyn OutputInterface>>) -> anyhow::Result<i64> {
let scripts = self.get_scripts()?;
if scripts.is_empty() {
return Ok(0);
@@ -81,7 +80,7 @@ impl RunScriptCommand {
Ok(0)
}
- fn get_scripts(&self) -> Result<Vec<(String, String)>> {
+ fn get_scripts(&self) -> anyhow::Result<Vec<(String, String)>> {
let composer = self.require_composer(None, None)?;
let scripts = crate::composer::composer_full(&composer)
.get_package()
diff --git a/crates/shirabe/src/command/script_alias_command.rs b/crates/shirabe/src/command/script_alias_command.rs
index 20e2901..ff1fd3d 100644
--- a/crates/shirabe/src/command/script_alias_command.rs
+++ b/crates/shirabe/src/command/script_alias_command.rs
@@ -6,7 +6,6 @@ use crate::command::base_command::base_command_initialize;
use crate::console::input::InputArgument;
use crate::console::input::InputOption;
use crate::util::Platform;
-use anyhow::Result;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
@@ -25,7 +24,11 @@ pub struct ScriptAliasCommand {
}
impl ScriptAliasCommand {
- pub fn new(script: String, description: Option<String>, aliases: Vec<String>) -> Result<Self> {
+ pub fn new(
+ script: String,
+ description: Option<String>,
+ aliases: Vec<String>,
+ ) -> anyhow::Result<Self> {
let description = description
.unwrap_or_else(|| format!("Runs the {} script as defined in composer.json", script));
diff --git a/crates/shirabe/src/command/search_command.rs b/crates/shirabe/src/command/search_command.rs
index 6f3f4ce..3e85d78 100644
--- a/crates/shirabe/src/command/search_command.rs
+++ b/crates/shirabe/src/command/search_command.rs
@@ -12,7 +12,6 @@ use crate::repository::CompositeRepository;
use crate::repository::PlatformRepository;
use crate::repository::RepositoryInterfaceHandle;
use crate::repository::repository_interface::{self, RepositoryInterface};
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::formatter::OutputFormatter;
diff --git a/crates/shirabe/src/command/self_update_command.rs b/crates/shirabe/src/command/self_update_command.rs
index ca567ce..35a1374 100644
--- a/crates/shirabe/src/command/self_update_command.rs
+++ b/crates/shirabe/src/command/self_update_command.rs
@@ -7,7 +7,6 @@ use crate::console::input::InputArgument;
use crate::console::input::InputOption;
use crate::io::IOInterfaceImmutable;
use crate::io::io_interface;
-use anyhow::Result;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;
diff --git a/crates/shirabe/src/command/show_command.rs b/crates/shirabe/src/command/show_command.rs
index 4f7403d..68b42e6 100644
--- a/crates/shirabe/src/command/show_command.rs
+++ b/crates/shirabe/src/command/show_command.rs
@@ -32,7 +32,6 @@ use crate::repository::RepositorySet;
use crate::repository::RepositoryUtils;
use crate::repository::RootPackageRepository;
use crate::util::PackageInfo;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::{CaptureKey, Preg};
use shirabe_external_packages::symfony::console::command::command::Command;
diff --git a/crates/shirabe/src/command/status_command.rs b/crates/shirabe/src/command/status_command.rs
index bec6868..3b3445b 100644
--- a/crates/shirabe/src/command/status_command.rs
+++ b/crates/shirabe/src/command/status_command.rs
@@ -12,7 +12,6 @@ use crate::plugin::CommandEvent;
use crate::plugin::PluginEvents;
use crate::script::ScriptEvents;
use crate::util::ProcessExecutor;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
@@ -49,7 +48,7 @@ impl StatusCommand {
fn do_execute(
&self,
input: std::rc::Rc<std::cell::RefCell<dyn InputInterface>>,
- ) -> Result<i64> {
+ ) -> anyhow::Result<i64> {
let composer = self.require_composer(None, None)?;
let composer = crate::composer::composer_full(&composer);
let io = self.get_io().clone();
diff --git a/crates/shirabe/src/command/suggests_command.rs b/crates/shirabe/src/command/suggests_command.rs
index 25b2e92..f7b0414 100644
--- a/crates/shirabe/src/command/suggests_command.rs
+++ b/crates/shirabe/src/command/suggests_command.rs
@@ -10,7 +10,6 @@ use crate::repository::PlatformRepository;
use crate::repository::RepositoryInterface;
use crate::repository::RepositoryInterfaceHandle;
use crate::repository::RootPackageRepository;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
@@ -112,7 +111,7 @@ impl Command for SuggestsCommand {
&self,
input: Rc<RefCell<dyn InputInterface>>,
_output: Rc<RefCell<dyn OutputInterface>>,
- ) -> Result<i64> {
+ ) -> anyhow::Result<i64> {
let composer = self.require_composer(None, None)?;
let composer = crate::composer::composer_full(&composer);
diff --git a/crates/shirabe/src/command/update_command.rs b/crates/shirabe/src/command/update_command.rs
index cce4829..366cf8b 100644
--- a/crates/shirabe/src/command/update_command.rs
+++ b/crates/shirabe/src/command/update_command.rs
@@ -23,7 +23,6 @@ use crate::repository::CompositeRepository;
use crate::repository::PlatformRepository;
use crate::repository::RepositorySet;
use crate::util::HttpDownloader;
-use anyhow::Result;
use indexmap::IndexMap;
use shirabe_external_packages::composer::pcre::Preg;
use shirabe_external_packages::symfony::console::command::command::Command;
@@ -602,7 +601,7 @@ impl UpdateCommand {
output: std::rc::Rc<std::cell::RefCell<dyn OutputInterface>>,
composer: &PartialComposerHandle,
packages: Vec<String>,
- ) -> Result<Vec<String>> {
+ ) -> anyhow::Result<Vec<String>> {
if !input.borrow().is_interactive() {
return Err(InvalidArgumentException {
message: "--interactive cannot be used in non-interactive terminals.".to_string(),
@@ -747,7 +746,10 @@ impl UpdateCommand {
.into())
}
- fn create_version_selector(&self, composer: &PartialComposerHandle) -> Result<VersionSelector> {
+ fn create_version_selector(
+ &self,
+ composer: &PartialComposerHandle,
+ ) -> anyhow::Result<VersionSelector> {
let composer = crate::composer::composer_full(composer);
let root_aliases: Vec<crate::repository::RootAliasInput> = composer
.get_package()
diff --git a/crates/shirabe/src/command/validate_command.rs b/crates/shirabe/src/command/validate_command.rs
index ab88398..bceaa99 100644
--- a/crates/shirabe/src/command/validate_command.rs
+++ b/crates/shirabe/src/command/validate_command.rs
@@ -13,7 +13,6 @@ use crate::plugin::CommandEvent;
use crate::plugin::PluginEvents;
use crate::util::ConfigValidator;
use crate::util::Filesystem;
-use anyhow::Result;
use shirabe_external_packages::symfony::console::command::command::Command;
use shirabe_external_packages::symfony::console::input::InputInterface;
use shirabe_external_packages::symfony::console::output::OutputInterface;