Skip to content

Add wildcard/glob pattern support to pm:install and pm:uninstall#6527

Open
philoSurfer wants to merge 1 commit intodrush-ops:14.xfrom
philoSurfer:feature/pm-wildcard-support
Open

Add wildcard/glob pattern support to pm:install and pm:uninstall#6527
philoSurfer wants to merge 1 commit intodrush-ops:14.xfrom
philoSurfer:feature/pm-wildcard-support

Conversation

@philoSurfer
Copy link

Summary

Re-adds wildcard expansion for module names in pm:install and pm:uninstall commands. This feature existed in Drush 7 (drupal.org #779612) but was lost during the Drush 9 rewrite.

Closes #6526

Changes

  • PmTrait::expandWildcards() — New protected method that expands * glob patterns against the available module extension list using regex matching
  • PmInstallCommand — Calls expandWildcards() after CSV parsing in both execute() and validateModules()
  • PmUninstallCommand — Calls expandWildcards() after CSV parsing in both execute() and validateUninstall()
  • Updated argument descriptions and added usage examples documenting wildcard support

Design Decisions

  • Placed in PmTrait so both install and uninstall inherit it without duplication
  • Zero overhead when unused — short-circuits immediately if no * characters are present (no extension list lookup)
  • Warning on no matches — logs a warning rather than silently doing nothing when a pattern matches zero modules
  • Full glob support* can appear anywhere in the name (prefix, suffix, or middle), not just trailing

Examples

drush pm:install "views*"            # Install all views-related modules
drush pm:install "commerce*"         # Install all commerce modules
drush pm:uninstall "devel*"          # Uninstall devel and related modules
drush pm:install --dry-run "field*"  # Preview what would be installed

Test Plan

  • drush pm:install --dry-run "views*" expands to matching modules
  • drush pm:uninstall --dry-run "nonexistent*" shows warning
  • drush pm:install admin_toolbar (no wildcard) works unchanged
  • Patterns with * in the middle work (e.g. field_*_storage)

Re-adds wildcard expansion for module names that was available in Drush 7
but lost during the Drush 9 rewrite. Module names containing '*' are
expanded against the available extension list before dependency resolution.

Examples:
  drush pm:install "views*"
  drush pm:uninstall "devel*"

The expandWildcards() method is placed in PmTrait so both install and
uninstall commands benefit. When no wildcards are present, the method
returns immediately with zero overhead (no extension list lookup).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add wildcard/glob pattern support to pm:install and pm:uninstall

1 participant