Skip to content

Feature/for each and subcommands #14

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

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

adam-huganir
Copy link
Owner

also adding an append option for multiple list inputs

@adam-huganir adam-huganir requested a review from Copilot May 20, 2025 02:18
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the template and file handling logic while adding new subcommands for “template” and “for-each” along with an append option for merging list data. Key changes include:

  • Removal of version management in internal/version.go (with version now managed in cmd/yutc/root.go).
  • Significant refactoring in file and template loading functions across internal, cmd/yutc, and related files.
  • Introduction of an append flag in internal/args.go and related modifications for handling list merges.

Reviewed Changes

Copilot reviewed 24 out of 24 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
internal/version.go Removed legacy version functions; version now handled in root.go
internal/util.go Updated generic must() function and added CmpTemplatePathLength
internal/types.go Added YutcTemplate with new template management functions
internal/template.go Refactored template and file loading functions
internal/funcMap.go Introduced a dedicated funcMap
internal/files.go Updated file reading with error wrapping and URL auth improvements
internal/data.go Updated merging logic and renamed MergeData to GatherData
internal/args.go Added an Append flag
go.mod Dependency version updates and additions
docs/diagram.py New diagram generation file
cmd/yutc/* Updated CLI commands for template and for-each operations
Taskfile.yaml New task definitions including build and exec tasks
.editorconfig Minor formatting updates

if settings.BasicAuth != "" {
username := strings.SplitN(settings.BearerToken, ":", 2)
if basicAuth != "" {
username := strings.SplitN(bearerToken, ":", 2)
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

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

When BasicAuth is provided, the code still splits the bearerToken string instead of basicAuth. Consider replacing 'bearerToken' with 'basicAuth' in the SplitN call to correctly process basic authentication credentials.

Suggested change
username := strings.SplitN(bearerToken, ":", 2)
username := strings.SplitN(basicAuth, ":", 2)

Copilot uses AI. Check for mistakes.

Comment on lines +127 to +134
func (t *YutcTemplate) Template() *template.Template {
var err error
// Make sure than any added templates have not overwritten the original template.
t.template, err = t.template.Parse(t.templateString)
if err != nil {
panic(fmt.Errorf("this should have been caught during NewTemplate call: %w", err))
}
return t.template
Copy link
Preview

Copilot AI May 20, 2025

Choose a reason for hiding this comment

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

[nitpick] Using panic here may abruptly crash the application in production. Consider returning an error from the Template() method or handling the error gracefully instead of panicking.

Suggested change
func (t *YutcTemplate) Template() *template.Template {
var err error
// Make sure than any added templates have not overwritten the original template.
t.template, err = t.template.Parse(t.templateString)
if err != nil {
panic(fmt.Errorf("this should have been caught during NewTemplate call: %w", err))
}
return t.template
func (t *YutcTemplate) Template() (*template.Template, error) {
var err error
// Make sure than any added templates have not overwritten the original template.
t.template, err = t.template.Parse(t.templateString)
if err != nil {
return nil, fmt.Errorf("this should have been caught during NewTemplate call: %w", err)
}
return t.template, nil

Copilot uses AI. Check for mistakes.

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.

feature: add for-each ability for multiple data in files (or maybe for a list input as well?)
1 participant