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

Deep suggestions based on task names #2731

Merged
merged 6 commits into from
Sep 12, 2023
Merged

Conversation

lihaoyi
Copy link
Member

@lihaoyi lihaoyi commented Sep 11, 2023

This PR adds an addition suggestion to the Try ... to see what's available error message based on the task names present in the entire build.

Before:

$ ./mill -i dev.run example/scalabuilds/10-scala-realistic -i Compilee
Cannot resolve Compilee. Try `mill resolve _` to see what's available.

After:

$ ./mill -i dev.run example/scalabuilds/10-scala-realistic -i Compilee
Cannot resolve Compilee. Try `mill resolve _` or `mill resolve __.compile` to see what's available.

This should help in the common case where someone runs a task with the correct name but in the wrong module. We do a fuzzy match, so even if there's a small typo we still are able to give a suggestion. This is complementary to the existing help message, which is useful when the user runs a task with the wrong name but in the correct module

The way this works is that we capture all the non-command task names in the Discover macro, and when a user runs a task that fails to resolve, we look at the last segment of the query and run a fuzzy search against the set. If a fuzzy match is found, we suggest to the user to run mill resolve __.foo so they have a way to see what the fully-qualified name of the task they were trying to run, and run it. Given the typical build would have O(10s) to O(100s) of modules at most, we can expect even the most verbose mill resolve __.foo outputs to be small enough that the user can browse through and find what they want

@lihaoyi lihaoyi requested review from lefou and lolgab September 11, 2023 15:34
@lihaoyi lihaoyi merged commit 69954eb into com-lihaoyi:main Sep 12, 2023
37 checks passed
@lefou lefou added this to the 0.11.3 milestone Sep 12, 2023
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.

2 participants