grim/wasdead

Add a command to clean up the database
draft
2019-05-10, Gary Kramlich
5c237823f4c9
Parents 290c54cfd71a
Children b81ba75f65cb
Add a command to clean up the database
  • +13 -0
    commands/tidy.go
  • +4 -2
    main.go
  • --- /dev/null Thu Jan 01 00:00:00 1970 +0000
    +++ b/commands/tidy.go Fri May 10 23:42:03 2019 -0500
    @@ -0,0 +1,13 @@
    +package commands
    +
    +import (
    + "github.com/prologic/bitcask"
    +
    + "bitbucket.org/TheToyz/nowdead/globals"
    +)
    +
    +type TidyCmd struct{}
    +
    +func (c *TidyCmd) Run(g *globals.Globals) error {
    + return bitcask.Merge(g.DatabasePath, false)
    +}
    --- a/main.go Fri May 10 23:31:45 2019 -0500
    +++ b/main.go Fri May 10 23:42:03 2019 -0500
    @@ -5,6 +5,7 @@
    "github.com/alecthomas/kong"
    + "bitbucket.org/TheToyz/nowdead/commands"
    "bitbucket.org/TheToyz/nowdead/globals"
    "bitbucket.org/TheToyz/nowdead/run"
    )
    @@ -23,8 +24,9 @@
    type cli struct {
    globals.Globals
    - Run run.RunCmd `kong:"cmd,help='Run the bot'"`
    - Version versionCmd `kong:"cmd,help='Display the version of this program'"`
    + Run run.RunCmd `kong:"cmd,help='Run the bot'"`
    + Tidy commands.TidyCmd `kong:"cmd,help='clean up the database'"`
    + Version versionCmd `kong:"cmd,help='Display the version of this program'"`
    }
    func main() {