feat(aa): add a string method to all rule struct.

This commit is contained in:
Alexandre Pujol 2024-04-23 21:26:09 +01:00
parent e9fa0660f8
commit 5483668574
No known key found for this signature in database
GPG key ID: C5469996F0DF68EC
20 changed files with 337 additions and 34 deletions

View file

@ -6,6 +6,12 @@ package aa
import (
"slices"
const (
tokABI = "abi"
tokALIAS = "alias"
tokINCLUDE = "include"
tokIFEXISTS = "if exists"
)
type Abi struct {
@ -27,6 +33,10 @@ func (r *Abi) Equals(other any) bool {
return r.Path == o.Path && r.IsMagic == o.IsMagic
}
func (r *Abi) String() string {
return renderTemplate(tokABI, r)
}
type Alias struct {
RuleBase
Path string
@ -46,6 +56,10 @@ func (r Alias) Equals(other any) bool {
return r.Path == o.Path && r.RewrittenPath == o.RewrittenPath
}
func (r *Alias) String() string {
return renderTemplate(tokALIAS, r)
}
type Include struct {
RuleBase
IfExists bool
@ -69,6 +83,10 @@ func (r *Include) Equals(other any) bool {
return r.Path == o.Path && r.IsMagic == o.IsMagic && r.IfExists == o.IfExists
}
func (r *Include) String() string {
return renderTemplate(tokINCLUDE, r)
}
type Variable struct {
RuleBase
Name string
@ -90,3 +108,7 @@ func (r *Variable) Equals(other any) bool {
o, _ := other.(*Variable)
return r.Name == o.Name && slices.Equal(r.Values, o.Values)
}
func (r *Variable) String() string {
return renderTemplate("variable", r)
}