镜像自地址
https://github.com/quitesimpleorg/hs9001.git
已同步 2025-03-16 05:13:32 +01:00
父节点
0949ee422a
当前提交
ebcdfa5ff4
20
main.go
20
main.go
@ -398,13 +398,31 @@ func main() {
|
|||||||
results := search(conn, opts)
|
results := search(conn, opts)
|
||||||
|
|
||||||
previousCmd := ""
|
previousCmd := ""
|
||||||
|
|
||||||
|
fi, err := os.Stdout.Stat()
|
||||||
|
if err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
//Don't print colors if output is piped
|
||||||
|
printColors := true
|
||||||
|
if (fi.Mode() & os.ModeCharDevice) == 0 {
|
||||||
|
printColors = false
|
||||||
|
}
|
||||||
|
|
||||||
for e := results.Front(); e != nil; e = e.Next() {
|
for e := results.Front(); e != nil; e = e.Next() {
|
||||||
entry, ok := e.Value.(*HistoryEntry)
|
entry, ok := e.Value.(*HistoryEntry)
|
||||||
if !ok {
|
if !ok {
|
||||||
log.Panic("Failed to retrieve entries")
|
log.Panic("Failed to retrieve entries")
|
||||||
}
|
}
|
||||||
if !distinct || previousCmd != entry.cmd {
|
if !distinct || previousCmd != entry.cmd {
|
||||||
fmt.Printf("%s\n", entry.cmd)
|
prefix := ""
|
||||||
|
postfix := ""
|
||||||
|
if printColors && entry.retval != 0 {
|
||||||
|
prefix = "\033[38;5;88m"
|
||||||
|
postfix = "\033[0m"
|
||||||
|
}
|
||||||
|
fmt.Printf("%s%s%s\n", prefix, entry.cmd, postfix)
|
||||||
}
|
}
|
||||||
previousCmd = entry.cmd
|
previousCmd = entry.cmd
|
||||||
}
|
}
|
||||||
|
正在加载...
x
在新工单中引用
屏蔽一个用户