summaryrefslogtreecommitdiff
path: root/plugin/plaintext
diff options
context:
space:
mode:
authorLoyalsoldier <[email protected]>2024-10-31 10:51:58 +0800
committerLoyalsoldier <[email protected]>2024-10-31 11:21:57 +0800
commit883184cbdc5fff0763c56aae7b08b0605dc08a9b (patch)
treeb1def962ecffe4c2d4be37e77597dd4772ae3e1f /plugin/plaintext
parent1e26c9803d42d3601c75c4db2ee3ff565b6388d8 (diff)
Feat: export input & output converters
Diffstat (limited to 'plugin/plaintext')
-rw-r--r--plugin/plaintext/clash_in.go24
-rw-r--r--plugin/plaintext/clash_out.go24
-rw-r--r--plugin/plaintext/common_in.go26
-rw-r--r--plugin/plaintext/common_out.go34
-rw-r--r--plugin/plaintext/json_in.go12
-rw-r--r--plugin/plaintext/surge_in.go12
-rw-r--r--plugin/plaintext/surge_out.go12
-rw-r--r--plugin/plaintext/text_in.go36
-rw-r--r--plugin/plaintext/text_out.go22
9 files changed, 101 insertions, 101 deletions
diff --git a/plugin/plaintext/clash_in.go b/plugin/plaintext/clash_in.go
index 7cf36338..78af932f 100644
--- a/plugin/plaintext/clash_in.go
+++ b/plugin/plaintext/clash_in.go
@@ -12,25 +12,25 @@ which make it possible to support more formats for the project.
*/
const (
- typeClashRuleSetClassicalIn = "clashRuleSetClassical"
- descClashClassicalIn = "Convert classical type of Clash RuleSet to other formats (just processing IP & CIDR lines)"
+ TypeClashRuleSetClassicalIn = "clashRuleSetClassical"
+ DescClashClassicalIn = "Convert classical type of Clash RuleSet to other formats (just processing IP & CIDR lines)"
- typeClashRuleSetIPCIDRIn = "clashRuleSet"
- descClashRuleSetIn = "Convert ipcidr type of Clash RuleSet to other formats"
+ TypeClashRuleSetIPCIDRIn = "clashRuleSet"
+ DescClashRuleSetIn = "Convert ipcidr type of Clash RuleSet to other formats"
)
func init() {
- lib.RegisterInputConfigCreator(typeClashRuleSetClassicalIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) {
- return newTextIn(typeClashRuleSetClassicalIn, action, data)
+ lib.RegisterInputConfigCreator(TypeClashRuleSetClassicalIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) {
+ return newTextIn(TypeClashRuleSetClassicalIn, action, data)
})
- lib.RegisterInputConverter(typeClashRuleSetClassicalIn, &textIn{
- Description: descClashClassicalIn,
+ lib.RegisterInputConverter(TypeClashRuleSetClassicalIn, &TextIn{
+ Description: DescClashClassicalIn,
})
- lib.RegisterInputConfigCreator(typeClashRuleSetIPCIDRIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) {
- return newTextIn(typeClashRuleSetIPCIDRIn, action, data)
+ lib.RegisterInputConfigCreator(TypeClashRuleSetIPCIDRIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) {
+ return newTextIn(TypeClashRuleSetIPCIDRIn, action, data)
})
- lib.RegisterInputConverter(typeClashRuleSetIPCIDRIn, &textIn{
- Description: descClashRuleSetIn,
+ lib.RegisterInputConverter(TypeClashRuleSetIPCIDRIn, &TextIn{
+ Description: DescClashRuleSetIn,
})
}
diff --git a/plugin/plaintext/clash_out.go b/plugin/plaintext/clash_out.go
index a7feab75..28071c84 100644
--- a/plugin/plaintext/clash_out.go
+++ b/plugin/plaintext/clash_out.go
@@ -12,25 +12,25 @@ which make it possible to support more formats for the project.
*/
const (
- typeClashRuleSetClassicalOut = "clashRuleSetClassical"
- descClashClassicalOut = "Convert data to classical type of Clash RuleSet"
+ TypeClashRuleSetClassicalOut = "clashRuleSetClassical"
+ DescClashClassicalOut = "Convert data to classical type of Clash RuleSet"
- typeClashRuleSetIPCIDROut = "clashRuleSet"
- descClashRuleSetOut = "Convert data to ipcidr type of Clash RuleSet"
+ TypeClashRuleSetIPCIDROut = "clashRuleSet"
+ DescClashRuleSetOut = "Convert data to ipcidr type of Clash RuleSet"
)
func init() {
- lib.RegisterOutputConfigCreator(typeClashRuleSetClassicalOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) {
- return newTextOut(typeClashRuleSetClassicalOut, action, data)
+ lib.RegisterOutputConfigCreator(TypeClashRuleSetClassicalOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) {
+ return newTextOut(TypeClashRuleSetClassicalOut, action, data)
})
- lib.RegisterOutputConverter(typeClashRuleSetClassicalOut, &textOut{
- Description: descClashClassicalOut,
+ lib.RegisterOutputConverter(TypeClashRuleSetClassicalOut, &TextOut{
+ Description: DescClashClassicalOut,
})
- lib.RegisterOutputConfigCreator(typeClashRuleSetIPCIDROut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) {
- return newTextOut(typeClashRuleSetIPCIDROut, action, data)
+ lib.RegisterOutputConfigCreator(TypeClashRuleSetIPCIDROut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) {
+ return newTextOut(TypeClashRuleSetIPCIDROut, action, data)
})
- lib.RegisterOutputConverter(typeClashRuleSetIPCIDROut, &textOut{
- Description: descClashRuleSetOut,
+ lib.RegisterOutputConverter(TypeClashRuleSetIPCIDROut, &TextOut{
+ Description: DescClashRuleSetOut,
})
}
diff --git a/plugin/plaintext/common_in.go b/plugin/plaintext/common_in.go
index 06032c9d..cc7728b1 100644
--- a/plugin/plaintext/common_in.go
+++ b/plugin/plaintext/common_in.go
@@ -11,7 +11,7 @@ import (
"gopkg.in/yaml.v2"
)
-type textIn struct {
+type TextIn struct {
Type string
Action lib.Action
Description string
@@ -27,18 +27,18 @@ type textIn struct {
RemoveSuffixesInLine []string
}
-func (t *textIn) scanFile(reader io.Reader, entry *lib.Entry) error {
+func (t *TextIn) scanFile(reader io.Reader, entry *lib.Entry) error {
var err error
switch t.Type {
- case typeTextIn:
+ case TypeTextIn:
err = t.scanFileForTextIn(reader, entry)
- case typeJSONIn:
+ case TypeJSONIn:
err = t.scanFileForJSONIn(reader, entry)
- case typeClashRuleSetClassicalIn:
+ case TypeClashRuleSetClassicalIn:
err = t.scanFileForClashClassicalRuleSetIn(reader, entry)
- case typeClashRuleSetIPCIDRIn:
+ case TypeClashRuleSetIPCIDRIn:
err = t.scanFileForClashIPCIDRRuleSetIn(reader, entry)
- case typeSurgeRuleSetIn:
+ case TypeSurgeRuleSetIn:
err = t.scanFileForSurgeRuleSetIn(reader, entry)
default:
return lib.ErrNotSupportedFormat
@@ -47,7 +47,7 @@ func (t *textIn) scanFile(reader io.Reader, entry *lib.Entry) error {
return err
}
-func (t *textIn) scanFileForTextIn(reader io.Reader, entry *lib.Entry) error {
+func (t *TextIn) scanFileForTextIn(reader io.Reader, entry *lib.Entry) error {
scanner := bufio.NewScanner(reader)
for scanner.Scan() {
line := scanner.Text()
@@ -83,7 +83,7 @@ func (t *textIn) scanFileForTextIn(reader io.Reader, entry *lib.Entry) error {
return nil
}
-func (t *textIn) readClashRuleSetYAMLFile(reader io.Reader) ([]string, error) {
+func (t *TextIn) readClashRuleSetYAMLFile(reader io.Reader) ([]string, error) {
var payload struct {
Payload []string `yaml:"payload"`
}
@@ -100,7 +100,7 @@ func (t *textIn) readClashRuleSetYAMLFile(reader io.Reader) ([]string, error) {
return payload.Payload, nil
}
-func (t *textIn) scanFileForClashIPCIDRRuleSetIn(reader io.Reader, entry *lib.Entry) error {
+func (t *TextIn) scanFileForClashIPCIDRRuleSetIn(reader io.Reader, entry *lib.Entry) error {
payload, err := t.readClashRuleSetYAMLFile(reader)
if err != nil {
return err
@@ -119,7 +119,7 @@ func (t *textIn) scanFileForClashIPCIDRRuleSetIn(reader io.Reader, entry *lib.En
return nil
}
-func (t *textIn) scanFileForClashClassicalRuleSetIn(reader io.Reader, entry *lib.Entry) error {
+func (t *TextIn) scanFileForClashClassicalRuleSetIn(reader io.Reader, entry *lib.Entry) error {
payload, err := t.readClashRuleSetYAMLFile(reader)
if err != nil {
return err
@@ -154,7 +154,7 @@ func (t *textIn) scanFileForClashClassicalRuleSetIn(reader io.Reader, entry *lib
return nil
}
-func (t *textIn) scanFileForSurgeRuleSetIn(reader io.Reader, entry *lib.Entry) error {
+func (t *TextIn) scanFileForSurgeRuleSetIn(reader io.Reader, entry *lib.Entry) error {
scanner := bufio.NewScanner(reader)
for scanner.Scan() {
line := scanner.Text()
@@ -193,7 +193,7 @@ func (t *textIn) scanFileForSurgeRuleSetIn(reader io.Reader, entry *lib.Entry) e
return nil
}
-func (t *textIn) scanFileForJSONIn(reader io.Reader, entry *lib.Entry) error {
+func (t *TextIn) scanFileForJSONIn(reader io.Reader, entry *lib.Entry) error {
data, err := io.ReadAll(reader)
if err != nil {
return err
diff --git a/plugin/plaintext/common_out.go b/plugin/plaintext/common_out.go
index 117d48c7..4fc6375c 100644
--- a/plugin/plaintext/common_out.go
+++ b/plugin/plaintext/common_out.go
@@ -18,7 +18,7 @@ var (
defaultOutputDirForSurgeRuleSetOut = filepath.Join("./", "output", "surge")
)
-type textOut struct {
+type TextOut struct {
Type string
Action lib.Action
Description string
@@ -52,13 +52,13 @@ func newTextOut(iType string, action lib.Action, data json.RawMessage) (lib.Outp
if tmp.OutputDir == "" {
switch iType {
- case typeTextOut:
+ case TypeTextOut:
tmp.OutputDir = defaultOutputDirForTextOut
- case typeClashRuleSetClassicalOut:
+ case TypeClashRuleSetClassicalOut:
tmp.OutputDir = defaultOutputDirForClashRuleSetClassicalOut
- case typeClashRuleSetIPCIDROut:
+ case TypeClashRuleSetIPCIDROut:
tmp.OutputDir = defaultOutputDirForClashRuleSetIPCIDROut
- case typeSurgeRuleSetOut:
+ case TypeSurgeRuleSetOut:
tmp.OutputDir = defaultOutputDirForSurgeRuleSetOut
}
}
@@ -67,10 +67,10 @@ func newTextOut(iType string, action lib.Action, data json.RawMessage) (lib.Outp
tmp.OutputExt = ".txt"
}
- return &textOut{
+ return &TextOut{
Type: iType,
Action: action,
- Description: descTextOut,
+ Description: DescTextOut,
OutputDir: tmp.OutputDir,
OutputExt: tmp.OutputExt,
Want: tmp.Want,
@@ -82,7 +82,7 @@ func newTextOut(iType string, action lib.Action, data json.RawMessage) (lib.Outp
}, nil
}
-func (t *textOut) marshalBytes(entry *lib.Entry) ([]byte, error) {
+func (t *TextOut) marshalBytes(entry *lib.Entry) ([]byte, error) {
var err error
var entryCidr []string
@@ -100,13 +100,13 @@ func (t *textOut) marshalBytes(entry *lib.Entry) ([]byte, error) {
var buf bytes.Buffer
switch t.Type {
- case typeTextOut:
+ case TypeTextOut:
err = t.marshalBytesForTextOut(&buf, entryCidr)
- case typeClashRuleSetClassicalOut:
+ case TypeClashRuleSetClassicalOut:
err = t.marshalBytesForClashRuleSetClassicalOut(&buf, entryCidr)
- case typeClashRuleSetIPCIDROut:
+ case TypeClashRuleSetIPCIDROut:
err = t.marshalBytesForClashRuleSetIPCIDROut(&buf, entryCidr)
- case typeSurgeRuleSetOut:
+ case TypeSurgeRuleSetOut:
err = t.marshalBytesForSurgeRuleSetOut(&buf, entryCidr)
default:
return nil, lib.ErrNotSupportedFormat
@@ -118,7 +118,7 @@ func (t *textOut) marshalBytes(entry *lib.Entry) ([]byte, error) {
return buf.Bytes(), nil
}
-func (t *textOut) marshalBytesForTextOut(buf *bytes.Buffer, entryCidr []string) error {
+func (t *TextOut) marshalBytesForTextOut(buf *bytes.Buffer, entryCidr []string) error {
for _, cidr := range entryCidr {
if t.AddPrefixInLine != "" {
buf.WriteString(t.AddPrefixInLine)
@@ -132,7 +132,7 @@ func (t *textOut) marshalBytesForTextOut(buf *bytes.Buffer, entryCidr []string)
return nil
}
-func (t *textOut) marshalBytesForClashRuleSetClassicalOut(buf *bytes.Buffer, entryCidr []string) error {
+func (t *TextOut) marshalBytesForClashRuleSetClassicalOut(buf *bytes.Buffer, entryCidr []string) error {
buf.WriteString("payload:\n")
for _, cidr := range entryCidr {
ip, _, err := net.ParseCIDR(cidr)
@@ -151,7 +151,7 @@ func (t *textOut) marshalBytesForClashRuleSetClassicalOut(buf *bytes.Buffer, ent
return nil
}
-func (t *textOut) marshalBytesForClashRuleSetIPCIDROut(buf *bytes.Buffer, entryCidr []string) error {
+func (t *TextOut) marshalBytesForClashRuleSetIPCIDROut(buf *bytes.Buffer, entryCidr []string) error {
buf.WriteString("payload:\n")
for _, cidr := range entryCidr {
buf.WriteString(" - '")
@@ -162,7 +162,7 @@ func (t *textOut) marshalBytesForClashRuleSetIPCIDROut(buf *bytes.Buffer, entryC
return nil
}
-func (t *textOut) marshalBytesForSurgeRuleSetOut(buf *bytes.Buffer, entryCidr []string) error {
+func (t *TextOut) marshalBytesForSurgeRuleSetOut(buf *bytes.Buffer, entryCidr []string) error {
for _, cidr := range entryCidr {
ip, _, err := net.ParseCIDR(cidr)
if err != nil {
@@ -183,7 +183,7 @@ func (t *textOut) marshalBytesForSurgeRuleSetOut(buf *bytes.Buffer, entryCidr []
return nil
}
-func (t *textOut) writeFile(filename string, data []byte) error {
+func (t *TextOut) writeFile(filename string, data []byte) error {
if err := os.MkdirAll(t.OutputDir, 0755); err != nil {
return err
}
diff --git a/plugin/plaintext/json_in.go b/plugin/plaintext/json_in.go
index 784eba09..14af7c87 100644
--- a/plugin/plaintext/json_in.go
+++ b/plugin/plaintext/json_in.go
@@ -7,16 +7,16 @@ import (
)
const (
- typeJSONIn = "json"
- descJSONIn = "Convert JSON data to other formats"
+ TypeJSONIn = "json"
+ DescJSONIn = "Convert JSON data to other formats"
)
func init() {
- lib.RegisterInputConfigCreator(typeJSONIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) {
- return newTextIn(typeJSONIn, action, data)
+ lib.RegisterInputConfigCreator(TypeJSONIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) {
+ return newTextIn(TypeJSONIn, action, data)
})
- lib.RegisterInputConverter(typeJSONIn, &textIn{
- Description: descJSONIn,
+ lib.RegisterInputConverter(TypeJSONIn, &TextIn{
+ Description: DescJSONIn,
})
}
diff --git a/plugin/plaintext/surge_in.go b/plugin/plaintext/surge_in.go
index d409a782..ebe7f37a 100644
--- a/plugin/plaintext/surge_in.go
+++ b/plugin/plaintext/surge_in.go
@@ -12,15 +12,15 @@ which make it possible to support more formats for the project.
*/
const (
- typeSurgeRuleSetIn = "surgeRuleSet"
- descSurgeRuleSetIn = "Convert Surge RuleSet to other formats (just processing IP & CIDR lines)"
+ TypeSurgeRuleSetIn = "surgeRuleSet"
+ DescSurgeRuleSetIn = "Convert Surge RuleSet to other formats (just processing IP & CIDR lines)"
)
func init() {
- lib.RegisterInputConfigCreator(typeSurgeRuleSetIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) {
- return newTextIn(typeSurgeRuleSetIn, action, data)
+ lib.RegisterInputConfigCreator(TypeSurgeRuleSetIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) {
+ return newTextIn(TypeSurgeRuleSetIn, action, data)
})
- lib.RegisterInputConverter(typeSurgeRuleSetIn, &textIn{
- Description: descSurgeRuleSetIn,
+ lib.RegisterInputConverter(TypeSurgeRuleSetIn, &TextIn{
+ Description: DescSurgeRuleSetIn,
})
}
diff --git a/plugin/plaintext/surge_out.go b/plugin/plaintext/surge_out.go
index c3868423..6af83271 100644
--- a/plugin/plaintext/surge_out.go
+++ b/plugin/plaintext/surge_out.go
@@ -12,15 +12,15 @@ which make it possible to support more formats for the project.
*/
const (
- typeSurgeRuleSetOut = "surgeRuleSet"
- descSurgeRuleSetOut = "Convert data to Surge RuleSet"
+ TypeSurgeRuleSetOut = "surgeRuleSet"
+ DescSurgeRuleSetOut = "Convert data to Surge RuleSet"
)
func init() {
- lib.RegisterOutputConfigCreator(typeSurgeRuleSetOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) {
- return newTextOut(typeSurgeRuleSetOut, action, data)
+ lib.RegisterOutputConfigCreator(TypeSurgeRuleSetOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) {
+ return newTextOut(TypeSurgeRuleSetOut, action, data)
})
- lib.RegisterOutputConverter(typeSurgeRuleSetOut, &textOut{
- Description: descSurgeRuleSetOut,
+ lib.RegisterOutputConverter(TypeSurgeRuleSetOut, &TextOut{
+ Description: DescSurgeRuleSetOut,
})
}
diff --git a/plugin/plaintext/text_in.go b/plugin/plaintext/text_in.go
index 68d60eaa..f129c3cb 100644
--- a/plugin/plaintext/text_in.go
+++ b/plugin/plaintext/text_in.go
@@ -13,16 +13,16 @@ import (
)
const (
- typeTextIn = "text"
- descTextIn = "Convert plaintext IP & CIDR to other formats"
+ TypeTextIn = "text"
+ DescTextIn = "Convert plaintext IP & CIDR to other formats"
)
func init() {
- lib.RegisterInputConfigCreator(typeTextIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) {
- return newTextIn(typeTextIn, action, data)
+ lib.RegisterInputConfigCreator(TypeTextIn, func(action lib.Action, data json.RawMessage) (lib.InputConverter, error) {
+ return newTextIn(TypeTextIn, action, data)
})
- lib.RegisterInputConverter(typeTextIn, &textIn{
- Description: descTextIn,
+ lib.RegisterInputConverter(TypeTextIn, &TextIn{
+ Description: DescTextIn,
})
}
@@ -50,11 +50,11 @@ func newTextIn(iType string, action lib.Action, data json.RawMessage) (lib.Input
}
}
- if iType != typeTextIn && len(tmp.IPOrCIDR) > 0 {
+ if iType != TypeTextIn && len(tmp.IPOrCIDR) > 0 {
return nil, fmt.Errorf("❌ [type %s | action %s] ipOrCIDR is invalid for this input format", iType, action)
}
- if iType == typeJSONIn && len(tmp.JSONPath) == 0 {
+ if iType == TypeJSONIn && len(tmp.JSONPath) == 0 {
return nil, fmt.Errorf("❌ [type %s | action %s] missing jsonPath", iType, action)
}
@@ -77,10 +77,10 @@ func newTextIn(iType string, action lib.Action, data json.RawMessage) (lib.Input
}
}
- return &textIn{
+ return &TextIn{
Type: iType,
Action: action,
- Description: descTextIn,
+ Description: DescTextIn,
Name: tmp.Name,
URI: tmp.URI,
IPOrCIDR: tmp.IPOrCIDR,
@@ -94,19 +94,19 @@ func newTextIn(iType string, action lib.Action, data json.RawMessage) (lib.Input
}, nil
}
-func (t *textIn) GetType() string {
+func (t *TextIn) GetType() string {
return t.Type
}
-func (t *textIn) GetAction() lib.Action {
+func (t *TextIn) GetAction() lib.Action {
return t.Action
}
-func (t *textIn) GetDescription() string {
+func (t *TextIn) GetDescription() string {
return t.Description
}
-func (t *textIn) Input(container lib.Container) (lib.Container, error) {
+func (t *TextIn) Input(container lib.Container) (lib.Container, error) {
entries := make(map[string]*lib.Entry)
var err error
@@ -168,7 +168,7 @@ func (t *textIn) Input(container lib.Container) (lib.Container, error) {
return container, nil
}
-func (t *textIn) walkDir(dir string, entries map[string]*lib.Entry) error {
+func (t *TextIn) walkDir(dir string, entries map[string]*lib.Entry) error {
err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
if err != nil {
return err
@@ -187,7 +187,7 @@ func (t *textIn) walkDir(dir string, entries map[string]*lib.Entry) error {
return err
}
-func (t *textIn) walkLocalFile(path, name string, entries map[string]*lib.Entry) error {
+func (t *TextIn) walkLocalFile(path, name string, entries map[string]*lib.Entry) error {
entryName := ""
name = strings.TrimSpace(name)
if name != "" {
@@ -231,7 +231,7 @@ func (t *textIn) walkLocalFile(path, name string, entries map[string]*lib.Entry)
return nil
}
-func (t *textIn) walkRemoteFile(url, name string, entries map[string]*lib.Entry) error {
+func (t *TextIn) walkRemoteFile(url, name string, entries map[string]*lib.Entry) error {
resp, err := http.Get(url)
if err != nil {
return err
@@ -258,7 +258,7 @@ func (t *textIn) walkRemoteFile(url, name string, entries map[string]*lib.Entry)
return nil
}
-func (t *textIn) appendIPOrCIDR(ipOrCIDR []string, name string, entries map[string]*lib.Entry) error {
+func (t *TextIn) appendIPOrCIDR(ipOrCIDR []string, name string, entries map[string]*lib.Entry) error {
name = strings.ToUpper(name)
entry, found := entries[name]
diff --git a/plugin/plaintext/text_out.go b/plugin/plaintext/text_out.go
index cc51da95..41c6065b 100644
--- a/plugin/plaintext/text_out.go
+++ b/plugin/plaintext/text_out.go
@@ -10,32 +10,32 @@ import (
)
const (
- typeTextOut = "text"
- descTextOut = "Convert data to plaintext CIDR format"
+ TypeTextOut = "text"
+ DescTextOut = "Convert data to plaintext CIDR format"
)
func init() {
- lib.RegisterOutputConfigCreator(typeTextOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) {
- return newTextOut(typeTextOut, action, data)
+ lib.RegisterOutputConfigCreator(TypeTextOut, func(action lib.Action, data json.RawMessage) (lib.OutputConverter, error) {
+ return newTextOut(TypeTextOut, action, data)
})
- lib.RegisterOutputConverter(typeTextOut, &textOut{
- Description: descTextOut,
+ lib.RegisterOutputConverter(TypeTextOut, &TextOut{
+ Description: DescTextOut,
})
}
-func (t *textOut) GetType() string {
+func (t *TextOut) GetType() string {
return t.Type
}
-func (t *textOut) GetAction() lib.Action {
+func (t *TextOut) GetAction() lib.Action {
return t.Action
}
-func (t *textOut) GetDescription() string {
+func (t *TextOut) GetDescription() string {
return t.Description
}
-func (t *textOut) Output(container lib.Container) error {
+func (t *TextOut) Output(container lib.Container) error {
for _, name := range t.filterAndSortList(container) {
entry, found := container.GetEntry(name)
if !found {
@@ -57,7 +57,7 @@ func (t *textOut) Output(container lib.Container) error {
return nil
}
-func (t *textOut) filterAndSortList(container lib.Container) []string {
+func (t *TextOut) filterAndSortList(container lib.Container) []string {
excludeMap := make(map[string]bool)
for _, exclude := range t.Exclude {
if exclude = strings.ToUpper(strings.TrimSpace(exclude)); exclude != "" {