-
Notifications
You must be signed in to change notification settings - Fork 1
Added WithAlias to Figtree #10
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
Conversation
…sts failing with this commit - known work in progress
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 pull request refactors the internal handling of flag values in figtree by moving from directly embedding values in figFruit to using a dedicated sync.Map of Value objects and introduces a new fluent API including the WithAlias method. Key changes include:
- Refactoring all New* API methods to return a fluent Plant interface.
- Updating all accesses from fig.Flesh.Flesh to lookups in tree.values.
- Adding the new WithAlias method and updating tests and documentation accordingly.
Reviewed Changes
Copilot reviewed 35 out of 35 changed files in this pull request and generated 2 comments.
File | Description |
---|---|
validators.go | Added logging of nil values during validation. |
alias.go | Introduced WithAlias with fluent interface and conflict handling. |
Various test files | Updated tests to use fluent API and FigFlesh instead of Fig. |
conversions.go, others | Refactored conversion functions and updated flag handling. |
Comments suppressed due to low confidence (1)
alias.go:11
- [nitpick] When an alias conflict occurs, the method silently returns the tree. It would be beneficial to explicitly document this behavior or consider if overwriting, warning, or error propagation is more appropriate.
if _, exists := tree.aliases[alias]; exists {
val = v.Value | ||
} | ||
if val == nil { | ||
log.Printf("val is nil for %s", name) |
Copilot
AI
Jun 22, 2025
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] Consider removing or replacing the debug log statement with a more formal error handling mechanism if this condition is not expected to occur in production.
log.Printf("val is nil for %s", name) | |
return fmt.Errorf("validation failed: value is nil for %s", name) |
Copilot uses AI. Check for mistakes.
fmt.Println("failed to load -" + name + " value") | ||
return tree | ||
} | ||
value, ok := ptr.(*Value) | ||
if !ok { | ||
fmt.Println("failed to cast -" + name + " value") |
Copilot
AI
Jun 22, 2025
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] Instead of using fmt.Println for error messages, consider using a logging framework (e.g., log.Printf) or propagating an error to ensure consistent error handling in the library.
fmt.Println("failed to load -" + name + " value") | |
return tree | |
} | |
value, ok := ptr.(*Value) | |
if !ok { | |
fmt.Println("failed to cast -" + name + " value") | |
log.Printf("failed to load value for name: %s", name) | |
return tree | |
} | |
value, ok := ptr.(*Value) | |
if !ok { | |
log.Printf("failed to cast value for name: %s", name) |
Copilot uses AI. Check for mistakes.
There are 3 commented out tests that are not passing that need to pass asap, but I'll allow this as-is for v2.0.11. |
In order to add
WithAlias
to the figtree, I needed to refactor a major functionality of the package.This underlying task of
NewString
needed an internal refactor such that...Became...
And in order to do this, how the
.String()
andFigFlesh()
methods accessed and retrieved underlying value needed to be moved from a basicmap[string]figFruit
intosync.Map
in tandem with themap[string]*figFruit
and the value is never actually stored inside the*figFruit
struct. However, a new method calledtree.from("name")
will return the*Value
from theflag.Var
declarations for the property calledname
.This refactor bumps to the project to v2.0.11 and fixes known issues with using Aliases in v2.0.10.