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 {
_, _ = fmt.Fprintf(color.Output, "%s", entity.ParseLine(line).Json())
} else {
_, _ = fmt.Fprintf(color.Output, "%s\n", entity.ParseLine(line).ColorString())
_, _ = fmt.Fprintf(color.Output, "%s", entity.ParseLine(line).ColorString())
}
}
} else {
if isJson {
_, _ = fmt.Fprintf(color.Output, "%s", entity.ParseLine(strings.Join(args, " ")).Json())
} 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 {
var line strings.Builder
for _, e := range es {
s := e.Text
switch e.Type {
case TypeIPv4:
line.WriteString(color.GreenString(e.Text))
s = color.GreenString(e.Text)
case TypeIPv6:
line.WriteString(color.BlueString(e.Text))
s = color.BlueString(e.Text)
case TypeDomain:
line.WriteString(color.YellowString(e.Text))
default:
line.WriteString(e.Text)
s = color.YellowString(e.Text)
}
if e.Type != TypePlain {
if len(e.InfoText) > 0 {
line.WriteString(" [" + color.RedString(e.InfoText) + "] ")
}
if e.Type != TypePlain && len(e.InfoText) > 0 {
s += " [" + color.RedString(e.InfoText) + "] "
}
line.WriteString("\n")
line.WriteString(s)
}
return strings.TrimSpace(line.String())
return line.String()
}
func (es Entities) Json() string {