cargo-hack icon indicating copy to clipboard operation
cargo-hack copied to clipboard

Support glob patterns in package selection

Open leighmcculloch opened this issue 9 months ago • 3 comments

The cargo hack build command does not accept global patterns like *, ? or [].

However the cargo build command does.

For example:

cargo hack build:

$ cargo hack build --package 'test_*'
error: package ID specification `test_*` matched no packages

vs

cargo build:

$ cargo build --package 'test_*'
   Compiling test_workspace_lib v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/workspace_lib)
   Compiling test_errors v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/errors)
   Compiling test_multiimpl v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/multiimpl)
   Compiling test_add_u128 v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/add_u128)
   Compiling test_add_i128 v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/add_i128)
   Compiling test_workspace_contract v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/workspace_contract)
   Compiling test_modular v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/modular)
   Compiling test_events v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/events)
   Compiling test_auth v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/auth)
   Compiling test_empty v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/empty)
   Compiling test_import_contract v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/import_contract)
   Compiling test_fuzz v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/fuzz)
   Compiling test_udt v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/udt)
   Compiling test_empty2 v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/empty2)
   Compiling test_account v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/account)
   Compiling test_contract_data v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/contract_data)
   Compiling test_constructor v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/constructor)
   Compiling test_add_u64 v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/add_u64)
   Compiling test_alloc v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/alloc)
   Compiling test_logging v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/logging)
   Compiling test_invoke_contract v22.0.7 (/Users/leighmcculloch/Code/rs-soroban-sdk/tests/invoke_contract)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in 30.39s

It would be helpful if the hack build command also accepted globals for selecting multiple packages that fit a specific naming convention.

leighmcculloch avatar Mar 26 '25 11:03 leighmcculloch

I don't see a way that cargo metadata could be used unfortunately to power the glob matching.

leighmcculloch avatar Mar 26 '25 11:03 leighmcculloch

I would accept a PR to implement this.

taiki-e avatar Mar 26 '25 12:03 taiki-e

I would accept a PR to implement this.

Opened PR here:

  • https://github.com/taiki-e/cargo-hack/pull/278

leighmcculloch avatar May 22 '25 20:05 leighmcculloch