mirror of
https://github.com/chainreactors/spray.git
synced 2025-06-21 18:30:49 +00:00
-F新增从stdin中读, 并添加颜色参数
This commit is contained in:
parent
5ace37824a
commit
25188b24e8
@ -50,7 +50,7 @@ func Spray() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if option.Format != "" {
|
if option.Format != "" {
|
||||||
internal.Format(option.Format)
|
internal.Format(option.Format, !option.NoColor)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,10 +6,18 @@ import (
|
|||||||
"github.com/chainreactors/logs"
|
"github.com/chainreactors/logs"
|
||||||
"github.com/chainreactors/spray/pkg"
|
"github.com/chainreactors/spray/pkg"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"os"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Format(filename string) {
|
func Format(filename string, color bool) {
|
||||||
content, err := ioutil.ReadFile(filename)
|
var content []byte
|
||||||
|
var err error
|
||||||
|
if filename == "stdin" {
|
||||||
|
content, err = ioutil.ReadAll(os.Stdin)
|
||||||
|
} else {
|
||||||
|
content, err = ioutil.ReadFile(filename)
|
||||||
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -24,6 +32,10 @@ func Format(filename string) {
|
|||||||
results = append(results, &result)
|
results = append(results, &result)
|
||||||
}
|
}
|
||||||
for _, result := range results {
|
for _, result := range results {
|
||||||
logs.Log.Info(result.String())
|
if color {
|
||||||
|
logs.Log.Info(result.ColorString())
|
||||||
|
} else {
|
||||||
|
logs.Log.Info(result.String())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user