Allow user to open multiple files, for example 'boltbrowser *.db'
This commit is contained in:
parent
a3019e1e0a
commit
9cc6944303
@ -13,28 +13,18 @@ ProgramName is the name of the program
|
||||
*/
|
||||
const ProgramName = "boltbrowser"
|
||||
|
||||
var databaseFile string
|
||||
var databaseFiles []string
|
||||
var db *bolt.DB
|
||||
var memBolt *BoltDB
|
||||
|
||||
func main() {
|
||||
var err error
|
||||
|
||||
if len(os.Args) != 2 {
|
||||
fmt.Printf("Usage: %s <filename>\n", ProgramName)
|
||||
if len(os.Args) < 2 {
|
||||
fmt.Printf("Usage: %s <filename(s)>\n", ProgramName)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
databaseFile := os.Args[1]
|
||||
db, err = bolt.Open(databaseFile, 0600, nil)
|
||||
if err != nil {
|
||||
fmt.Printf("Error reading file: %q\n", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// First things first, load the database into memory
|
||||
memBolt.refreshDatabase()
|
||||
|
||||
err = termbox.Init()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -44,6 +34,17 @@ func main() {
|
||||
style := defaultStyle()
|
||||
termbox.SetOutputMode(termbox.Output256)
|
||||
|
||||
mainLoop(memBolt, style)
|
||||
defer db.Close()
|
||||
databaseFiles := os.Args[1:]
|
||||
for _, databaseFile := range databaseFiles {
|
||||
db, err = bolt.Open(databaseFile, 0600, nil)
|
||||
if err != nil {
|
||||
fmt.Printf("Error reading file: %q\n", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// First things first, load the database into memory
|
||||
memBolt.refreshDatabase()
|
||||
mainLoop(memBolt, style)
|
||||
defer db.Close()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user