Add user storage test
This commit is contained in:
parent
0c5b4bb04e
commit
137cf3224d
6 changed files with 105 additions and 33 deletions
|
@ -1,6 +1,9 @@
|
|||
package commands
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/khlieng/dispatch/Godeps/_workspace/src/github.com/spf13/cobra"
|
||||
|
||||
"github.com/khlieng/dispatch/storage"
|
||||
|
@ -8,8 +11,20 @@ import (
|
|||
|
||||
var clearCmd = &cobra.Command{
|
||||
Use: "clear",
|
||||
Short: "Clear all application data",
|
||||
Short: "Clear database and message logs",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
storage.Clear()
|
||||
err := os.Remove(storage.Path.Database())
|
||||
if err == nil || os.IsNotExist(err) {
|
||||
log.Println("Database cleared")
|
||||
} else {
|
||||
log.Println(err)
|
||||
}
|
||||
|
||||
err = os.RemoveAll(storage.Path.Logs())
|
||||
if err == nil {
|
||||
log.Println("Logs cleared")
|
||||
} else {
|
||||
log.Println(err)
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue