espelhamento de
https://github.com/quitesimpleorg/hs9001.git
sincronizado 2024-11-22 02:57:51 +01:00
search: Do not print consecutive equal commands by default
Esse commit está contido em:
pai
baa0d58a47
commit
3b01d7b898
9
main.go
9
main.go
@ -266,10 +266,12 @@ func main() {
|
|||||||
var workDir string
|
var workDir string
|
||||||
var beginTime string
|
var beginTime string
|
||||||
var endTime string
|
var endTime string
|
||||||
|
var distinct bool = true
|
||||||
|
|
||||||
searchCmd.StringVar(&workDir, "workdir", "%", "Search only within this workdir")
|
searchCmd.StringVar(&workDir, "workdir", "%", "Search only within this workdir")
|
||||||
searchCmd.StringVar(&beginTime, "begin", "50 years ago", "Start searching from this timeframe")
|
searchCmd.StringVar(&beginTime, "begin", "50 years ago", "Start searching from this timeframe")
|
||||||
searchCmd.StringVar(&endTime, "end", "now", "End searching from this timeframe")
|
searchCmd.StringVar(&endTime, "end", "now", "End searching from this timeframe")
|
||||||
|
searchCmd.BoolVar(&distinct, "distinct", true, "Remove consecutive duplicate commands from output")
|
||||||
|
|
||||||
searchCmd.Parse(globalargs)
|
searchCmd.Parse(globalargs)
|
||||||
|
|
||||||
@ -288,13 +290,16 @@ func main() {
|
|||||||
q := strings.Join(args, " ")
|
q := strings.Join(args, " ")
|
||||||
results := search(conn, "%"+q+"%", workDir, beginTimestamp, endTimeStamp)
|
results := search(conn, "%"+q+"%", workDir, beginTimestamp, endTimeStamp)
|
||||||
|
|
||||||
|
previousCmd := ""
|
||||||
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 {
|
||||||
fmt.Printf("%s\n", entry.cmd)
|
fmt.Printf("%s\n", entry.cmd)
|
||||||
|
}
|
||||||
|
previousCmd = entry.cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
if cmd == "delete" {
|
if cmd == "delete" {
|
||||||
|
Carregando…
Referência em uma nova issue
Block a user