fix: deterministic ordering of required var prompts#2871
Open
caproven wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Hello! Huge fan of task and while snooping through release notes found the relatively new feature of interactive prompting for required vars courtesy of #2579. The first run I used it for, with 2 required vars, it prompted for the vars backwards based on
Taskfile.ymldefinition order.I could only reproduce this some of the time, suggesting something like Go map traversal. Here's my Taskfile used for local testing before/after this change:
Based on #2579 there are 2 effective codepaths for interactive variable prompting to concern ourselves with, aligning with the tasks defined above:
When running
task deps --interactive, there was about a 50% chance on my end that the ordering was completely jumbled. The "cmds" path uses slices internally and I observed no behavioral sequencing issues (task cmds --interactive).Ordering
The solution presented in this PR is to preserve discovery order of required vars in the "deps" path. This felt the most intuitive to me but I'm open to suggestions. The present non-deterministic order threw me off so I figured it was unintentional.
Regardless of exact ordering, predictability helps with muscle memory (perhaps folks are quickly typing out the same vars in common tasks). I'd say more importantly it preserves semantics intended by the task developer. Take for instance
[HOST, PORT][IMAGE, TAG]In each of these cases, being prompted in reverse order would feel off.