-F新增从stdin中读, 并添加颜色参数

This commit is contained in:
M09Ic committed 2023-02-08 19:17:42 +08:00
1 parent 6faec1756a
commit 24b56af2d6
2 files changed
+16 -4

No files matched your search

+1 -1
View File
@@ -50,7 +50,7 @@ func Spray() {
}
if option.Format != "" {
internal.Format(option.Format)
internal.Format(option.Format, !option.NoColor)
os.Exit(0)
}
+15 -3
View File
@@ -6,10 +6,18 @@ import (
"github.com/chainreactors/logs"
"github.com/chainreactors/spray/pkg"
"io/ioutil"
"os"
)
func Format(filename string) {
content, err := ioutil.ReadFile(filename)
func Format(filename string, color bool) {
var content []byte
var err error
if filename == "stdin" {
content, err = ioutil.ReadAll(os.Stdin)
} else {
content, err = ioutil.ReadFile(filename)
}
if err != nil {
return
}
@@ -24,6 +32,10 @@ func Format(filename string) {
results = append(results, &result)
}
for _, result := range results {
logs.Log.Info(result.String())
if color {
logs.Log.Info(result.ColorString())
} else {
logs.Log.Info(result.String())
}
}
}