2015-05-01 23:02:21 +00:00
|
|
|
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-05-01 23:02:21 +00:00
|
|
|
|
2015-12-11 03:35:48 +00:00
|
|
|
"github.com/khlieng/dispatch/storage"
|
2015-05-01 23:02:21 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var clearCmd = &cobra.Command{
|
|
|
|
Use: "clear",
|
2016-01-15 01:27:30 +00:00
|
|
|
Short: "Clear all user data",
|
2015-05-01 23:02:21 +00:00
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2020-03-10 22:56:07 +00:00
|
|
|
err := os.Remove(storage.DataPath.Database())
|
2016-01-07 22:59:38 +00:00
|
|
|
if err == nil || os.IsNotExist(err) {
|
|
|
|
log.Println("Database cleared")
|
|
|
|
} else {
|
|
|
|
log.Println(err)
|
|
|
|
}
|
|
|
|
|
2020-03-10 22:56:07 +00:00
|
|
|
err = os.RemoveAll(storage.DataPath.Users())
|
2016-01-07 22:59:38 +00:00
|
|
|
if err == nil {
|
2016-01-15 01:27:30 +00:00
|
|
|
log.Println("User data cleared")
|
2016-01-07 22:59:38 +00:00
|
|
|
} else {
|
|
|
|
log.Println(err)
|
|
|
|
}
|
2015-05-01 23:02:21 +00:00
|
|
|
},
|
|
|
|
}
|