feat: detect hcl taskfiles #2
Merged
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.
Summary
Testing
go test ./taskfilego run ./cmd/task -d /tmp/hcltest(fails: HCL parsing not implemented)Prompt
Task 2: Extend Taskfile Discovery to HCL Files
Purpose: Allow the tool to recognize HCL-based Taskfiles. We will update the Taskfile search logic to include Taskfile.hcl (and an extensionless Taskfile) as valid config filenames, in addition to the existing YAML names. The code should detect these new filenames and route to the appropriate parser.
• Implementation:
• Modify the supported file names list (in the code that searches for Taskfiles) to include Taskfile.hcl and Taskfile (as well as lowercase variants for consistency, if applicable). The search order should be defined to avoid ambiguity when multiple formats are present. For initial implementation, you can list HCL files after the YAML files so that existing projects are not impacted (e.g. check YAML first, then HCL).
• Update any logic that prints the expected Taskfile name or checks for default filenames. For example, if an error says “Taskfile not found”, it should mention .hcl as well.
• For now, if an HCL file is found, call the HCL loader (from Task 1’s interface). If the HCL loader is not yet fully implemented, have it return a descriptive “not implemented” error. This allows incremental development without breaking the program flow.
• Validation:
• Write tests for the discovery logic. Example: create temp files Taskfile.hcl and Taskfile.yml in a directory and ensure the program finds the correct one according to the priority. Test that if only Taskfile.hcl exists, the loader is invoked (even if it errors out for now).
• Run the task command in a directory with an HCL Taskfile (containing minimal content like just a version) and verify that the program attempts to load it. It may error until HCL parse is implemented, but the error message should clearly indicate HCL is recognized (e.g. “HCL parsing not implemented” rather than “file not found”).
https://chatgpt.com/codex/tasks/task_e_6891fda49e7c8330bc713c77ca2d0502