A little smoothing out

This commit is contained in:
Brian Buller 2015-05-12 16:02:39 -05:00
parent 1d45a6f294
commit 1c7863fe49
1 changed files with 12 additions and 3 deletions

View File

@ -13,15 +13,24 @@ func main() {
fmt.Println("Usage: printbolt <Database File> [build]")
os.Exit(1)
}
db, err := bolt.Open(args[0], 0600, nil)
filename := args[0]
if len(args) > 1 && args[1] == "build" {
if _, err := os.Stat(filename); err == nil {
fmt.Printf("Cowardly refusing to overwrite file: %s\n", filename)
return
}
}
db, err := bolt.Open(filename, 0600, nil)
if err != nil {
fmt.Println(err)
}
defer db.Close()
if len(args) > 1 {
if args[1] == "gentest" {
// createTestDatabase(db)
if args[1] == "build" {
createTestDatabase(db)
} else if args[1] == "json" {
jsonDatabase(db)
}