From fe381ee41aab312110413150f00e5d617d177ffe Mon Sep 17 00:00:00 2001 From: Victor Häggqvist Date: Tue, 2 Feb 2016 03:22:27 +0100 Subject: add the stats command --- goboom.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'goboom.go') diff --git a/goboom.go b/goboom.go index 1948534..b8050c4 100644 --- a/goboom.go +++ b/goboom.go @@ -46,6 +46,7 @@ var ( prePhase bool postPhase bool launcher bool + stats bool dbFilePath string config Config ) @@ -166,10 +167,27 @@ func writeDB(itemSet map[string]int) { } } +func displayStats() { + items := openDB() + + sortedList := CmdList{} + for runnable, count := range items { + sortedList = append(sortedList, &Runnable{runnable, count}) + } + + sort.Sort(sortedList) + + fmt.Println("Name\tLaunch count") + for _, i := range sortedList { + fmt.Printf("%s\t%d\n", i.Cmd, i.Count) + } +} + func main() { flag.BoolVar(&prePhase, "pre", false, "Generate dmenu in") flag.BoolVar(&launcher, "launcher", false, "Output launcher command") flag.BoolVar(&postPhase, "post", false, "Update ranking DB") + flag.BoolVar(&stats, "stats", false, "View you statsB") flag.Parse() loadIni() @@ -188,6 +206,9 @@ func main() { fmt.Print(input) } else if launcher { fmt.Print("dmenu " + config.DmenuParams) + + } else if stats { + displayStats() } else { fmt.Printf("goboom v%d (%s/%s/%s)\n", version, runtime.GOOS, runtime.GOARCH, runtime.Version()) fmt.Println("\nTo actually use goboom execute goboom_run\n") -- cgit v1.2.3