1
0
mirror of https://github.com/zu1k/nali.git synced 2025-01-22 13:19:02 +08:00

revolt output behavior, making it consistent with the original.

This commit is contained in:
M09Ic 2023-05-21 14:10:31 +08:00
parent 97cde2aa94
commit 56be0c61ca
2 changed files with 12 additions and 13 deletions

View File

@ -77,14 +77,16 @@ Find document on: https://github.com/zu1k/nali
if isJson { if isJson {
_, _ = fmt.Fprintf(color.Output, "%s", entity.ParseLine(line).Json()) _, _ = fmt.Fprintf(color.Output, "%s", entity.ParseLine(line).Json())
} else { } else {
_, _ = fmt.Fprintf(color.Output, "%s\n", entity.ParseLine(line).ColorString()) _, _ = fmt.Fprintf(color.Output, "%s", entity.ParseLine(line).ColorString())
} }
} }
} else { } else {
if isJson { if isJson {
_, _ = fmt.Fprintf(color.Output, "%s", entity.ParseLine(strings.Join(args, " ")).Json()) _, _ = fmt.Fprintf(color.Output, "%s", entity.ParseLine(strings.Join(args, " ")).Json())
} else { } else {
_, _ = fmt.Fprintf(color.Output, "%s\n", entity.ParseLine(strings.Join(args, " ")).ColorString()) for _, line := range args {
_, _ = fmt.Fprintf(color.Output, "%s\n", entity.ParseLine(line).ColorString())
}
} }
} }
}, },

View File

@ -68,24 +68,21 @@ func (es Entities) String() string {
func (es Entities) ColorString() string { func (es Entities) ColorString() string {
var line strings.Builder var line strings.Builder
for _, e := range es { for _, e := range es {
s := e.Text
switch e.Type { switch e.Type {
case TypeIPv4: case TypeIPv4:
line.WriteString(color.GreenString(e.Text)) s = color.GreenString(e.Text)
case TypeIPv6: case TypeIPv6:
line.WriteString(color.BlueString(e.Text)) s = color.BlueString(e.Text)
case TypeDomain: case TypeDomain:
line.WriteString(color.YellowString(e.Text)) s = color.YellowString(e.Text)
default:
line.WriteString(e.Text)
} }
if e.Type != TypePlain { if e.Type != TypePlain && len(e.InfoText) > 0 {
if len(e.InfoText) > 0 { s += " [" + color.RedString(e.InfoText) + "] "
line.WriteString(" [" + color.RedString(e.InfoText) + "] ")
}
} }
line.WriteString("\n") line.WriteString(s)
} }
return strings.TrimSpace(line.String()) return line.String()
} }
func (es Entities) Json() string { func (es Entities) Json() string {