summaryrefslogtreecommitdiff
path: root/plugin
diff options
context:
space:
mode:
authorLoyalsoldier <[email protected]>2024-08-06 09:15:52 +0800
committerLoyalsoldier <[email protected]>2024-08-06 09:15:52 +0800
commitee2fd80a8ff2094c89a890857e0b7f285dff8f86 (patch)
treedd48f594485dad1306a02cbb5347e46adf0b9bbc /plugin
parentfa11a12015d982ef095442d38ef0f42a0559b2c6 (diff)
Feat: support to customize output file extension in all plaintext formats
Diffstat (limited to 'plugin')
-rw-r--r--plugin/plaintext/common_out.go7
-rw-r--r--plugin/plaintext/text_out.go4
2 files changed, 9 insertions, 2 deletions
diff --git a/plugin/plaintext/common_out.go b/plugin/plaintext/common_out.go
index cb38345d..ddc8d662 100644
--- a/plugin/plaintext/common_out.go
+++ b/plugin/plaintext/common_out.go
@@ -23,6 +23,7 @@ type textOut struct {
Action lib.Action
Description string
OutputDir string
+ OutputExt string
Want []string
OnlyIPType lib.IPType
@@ -33,6 +34,7 @@ type textOut struct {
func newTextOut(iType string, action lib.Action, data json.RawMessage) (lib.OutputConverter, error) {
var tmp struct {
OutputDir string `json:"outputDir"`
+ OutputExt string `json:"outputExtension"`
Want []string `json:"wantedList"`
OnlyIPType lib.IPType `json:"onlyIPType"`
@@ -59,11 +61,16 @@ func newTextOut(iType string, action lib.Action, data json.RawMessage) (lib.Outp
}
}
+ if tmp.OutputExt == "" {
+ tmp.OutputExt = ".txt"
+ }
+
return &textOut{
Type: iType,
Action: action,
Description: descTextOut,
OutputDir: tmp.OutputDir,
+ OutputExt: tmp.OutputExt,
Want: tmp.Want,
OnlyIPType: tmp.OnlyIPType,
diff --git a/plugin/plaintext/text_out.go b/plugin/plaintext/text_out.go
index 6db90388..10ad6143 100644
--- a/plugin/plaintext/text_out.go
+++ b/plugin/plaintext/text_out.go
@@ -50,7 +50,7 @@ func (t *textOut) Output(container lib.Container) error {
if err != nil {
return err
}
- filename := strings.ToLower(entry.GetName()) + ".txt"
+ filename := strings.ToLower(entry.GetName()) + t.OutputExt
if err := t.writeFile(filename, data); err != nil {
return err
}
@@ -67,7 +67,7 @@ func (t *textOut) Output(container lib.Container) error {
if err != nil {
return err
}
- filename := strings.ToLower(entry.GetName()) + ".txt"
+ filename := strings.ToLower(entry.GetName()) + t.OutputExt
if err := t.writeFile(filename, data); err != nil {
return err
}