diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-05-09 14:44:26 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-05-09 14:44:38 +0900 |
| commit | 0802fd44ed11283f15900d2993fc495acf1bed01 (patch) | |
| tree | e0e072dbbf3a7cbaa5f2be22682f6070ec2b7ea1 /crates/mozart/src/commands.rs | |
| parent | 75b15f58b778b4574e74c86c103b7e36baf4eeb3 (diff) | |
| download | php-mozart-0802fd44ed11283f15900d2993fc495acf1bed01.tar.gz php-mozart-0802fd44ed11283f15900d2993fc495acf1bed01.tar.zst php-mozart-0802fd44ed11283f15900d2993fc495acf1bed01.zip | |
refactor(commands): consolidate get_platform_requirement_filter into shared module
Removes the per-command duplicate implementations of
get_platform_requirement_filter from dump_autoload and reinstall,
and lifts a single canonical version into commands.rs.
Diffstat (limited to 'crates/mozart/src/commands.rs')
| -rw-r--r-- | crates/mozart/src/commands.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/crates/mozart/src/commands.rs b/crates/mozart/src/commands.rs index 1717437..f9b8880 100644 --- a/crates/mozart/src/commands.rs +++ b/crates/mozart/src/commands.rs @@ -312,3 +312,25 @@ pub async fn execute(cli: &Cli) -> anyhow::Result<()> { Commands::Validate(args) => validate::execute(args, cli, &console).await, } } + +/// Creates PlatformRequirementFilter from CLI options. Priority: +/// +/// 1. `--ignore-platform-reqs` → ignore every platform requirement +/// 2. `--ignore-platform-req <name>...` (non-empty) → ignore the listed names +/// 3. neither → ignore nothing +/// +/// ref: \Composer\Command\BaseCommand::getPlatformRequirementFilter() +pub(crate) fn get_platform_requirement_filter( + ignore_platform_reqs: bool, + ignore_platform_req: &[String], +) -> anyhow::Result<mozart_core::composer::PlatformRequirementFilter> { + use mozart_core::composer::PlatformRequirementFilter; + + if ignore_platform_reqs { + return Ok(PlatformRequirementFilter::ignore_all()); + } + if !ignore_platform_req.is_empty() { + return PlatformRequirementFilter::from_list(ignore_platform_req); + } + Ok(PlatformRequirementFilter::ignore_nothing()) +} |
