-
Notifications
You must be signed in to change notification settings - Fork 0
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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) |
There was a problem hiding this comment.
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.
username := strings.SplitN(bearerToken, ":", 2) | |
username := strings.SplitN(basicAuth, ":", 2) |
Copilot uses AI. Check for mistakes.
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 |
There was a problem hiding this comment.
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.
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.
also adding an
append
option for multiple list inputs