A little smoothing out

This commit is contained in:
Brian Buller 2015-05-12 16:02:39 -05:00
parent 1d45a6f294
commit 1c7863fe49

View File

@ -13,15 +13,24 @@ func main() {
fmt.Println("Usage: printbolt <Database File> [build]") fmt.Println("Usage: printbolt <Database File> [build]")
os.Exit(1) 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 { if err != nil {
fmt.Println(err) fmt.Println(err)
} }
defer db.Close() defer db.Close()
if len(args) > 1 { if len(args) > 1 {
if args[1] == "gentest" { if args[1] == "build" {
// createTestDatabase(db) createTestDatabase(db)
} else if args[1] == "json" { } else if args[1] == "json" {
jsonDatabase(db) jsonDatabase(db)
} }