From 0802fd44ed11283f15900d2993fc495acf1bed01 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sat, 9 May 2026 14:44:26 +0900 Subject: 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. --- crates/mozart/src/commands.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'crates/mozart/src/commands.rs') 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 ...` (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 { + 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()) +} -- cgit v1.3.1