Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(run): match tasks to run with glob patterns #1528

Merged
merged 1 commit into from
Jan 26, 2024

Conversation

Ajpantuso
Copy link
Contributor

Summary

Closes #1271

This change make it possible to select multiple tasks to run using glob style matching.
Task topics, separated by :, are treated like directories in shell matching such that patterns like a:**:d will match tasks named a:d, a:b:d or a:b:c:d.

Additional Notes

  • This brings globset in as a direct dependency, but it was transitive already.
  • Used an Extension Trait since tasks_with_aliases is used in multiple places making a more local change preferable though it may make sense to move this trait or change the return type of tasks_with_aliases in the future.

fn get_matching(&self, pat: &str) -> Result<Vec<&T>>;
}

impl<T> GetMatchingExt<T> for std::collections::HashMap<String, T> {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we go with BTreeMap? I think the output will look a little cleaner being not randomized by HashMap

IndexMap might also be a good idea but I'm not sure what order the tasks are in

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that decision would really have to be made here, but I can definitely add sorting to guarantee ordering.

Copy link
Owner

@jdx jdx Jan 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

up to you, could be in a different PR if you want. I'm not sure how many places that would need to change off the top of my head

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lol, played around with this a bit only to realize parallelization ends up randomizing the output ordering anyway. So I think we can defer the decision for now since ordering is only relevant for single threaded runs (which I imagine is the less likely use case).

src/cli/run.rs Outdated Show resolved Hide resolved
src/cli/run.rs Show resolved Hide resolved
@jdx
Copy link
Owner

jdx commented Jan 26, 2024

clever solution using the glob here. I was just going to have a naive wildcard match

@jdx
Copy link
Owner

jdx commented Jan 26, 2024

this could happen later, but this code should probably be updated to use glob logic as well:

.map(|name| match name.strip_suffix('*') {

@Ajpantuso
Copy link
Contributor Author

this could happen later, but this code should probably be updated to use glob logic as well:

.map(|name| match name.strip_suffix('*') {

I can pick that up in a follow up.

@jdx jdx merged commit 7b3ae2e into jdx:main Jan 26, 2024
7 checks passed
@Ajpantuso Ajpantuso deleted the apantuso/run_globs branch January 26, 2024 00:59
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.

rtx run lint:*
2 participants