dispatch/commands/clear.go

31 lines
530 B
Go
Raw Permalink Normal View History

package commands
import (
2016-01-07 22:59:38 +00:00
"log"
"os"
2016-03-01 00:51:26 +00:00
"github.com/spf13/cobra"
2015-12-11 03:35:48 +00:00
"github.com/khlieng/dispatch/storage"
)
var clearCmd = &cobra.Command{
Use: "clear",
Short: "Clear all user data",
Run: func(cmd *cobra.Command, args []string) {
2020-04-20 01:02:15 +00:00
err := os.Remove(storage.Path.Database())
2016-01-07 22:59:38 +00:00
if err == nil || os.IsNotExist(err) {
log.Println("Database cleared")
} else {
log.Println(err)
}
2020-04-20 01:02:15 +00:00
err = os.RemoveAll(storage.Path.Users())
2016-01-07 22:59:38 +00:00
if err == nil {
log.Println("User data cleared")
2016-01-07 22:59:38 +00:00
} else {
log.Println(err)
}
},
}