Add config file, handle it with Viper, add a command to open it in an editor
This commit is contained in:
parent
b8a8ba2e08
commit
61aa5880d3
234 changed files with 44636 additions and 383 deletions
|
@ -10,7 +10,7 @@ import (
|
|||
)
|
||||
|
||||
var (
|
||||
appDir string
|
||||
AppDir string
|
||||
|
||||
db *bolt.DB
|
||||
|
||||
|
@ -26,18 +26,18 @@ func init() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
appDir = path.Join(currentUser.HomeDir, ".name_pending")
|
||||
AppDir = path.Join(currentUser.HomeDir, ".name_pending")
|
||||
|
||||
os.Mkdir(AppDir, 0777)
|
||||
os.Mkdir(path.Join(AppDir, "logs"), 0777)
|
||||
}
|
||||
|
||||
func Initialize() {
|
||||
var err error
|
||||
|
||||
log.Println("Storing data at", appDir)
|
||||
log.Println("Storing data at", AppDir)
|
||||
|
||||
os.Mkdir(appDir, 0777)
|
||||
os.Mkdir(path.Join(appDir, "logs"), 0777)
|
||||
|
||||
db, err = bolt.Open(path.Join(appDir, "data.db"), 0600, nil)
|
||||
db, err = bolt.Open(path.Join(AppDir, "data.db"), 0600, nil)
|
||||
if err != nil {
|
||||
log.Fatal("Could not open database file")
|
||||
}
|
||||
|
@ -56,5 +56,6 @@ func Close() {
|
|||
}
|
||||
|
||||
func Clear() {
|
||||
os.RemoveAll(appDir)
|
||||
os.RemoveAll(path.Join(AppDir, "logs"))
|
||||
os.Remove(path.Join(AppDir, "data.db"))
|
||||
}
|
||||
|
|
|
@ -304,7 +304,7 @@ func (u *User) SearchMessages(server, channel, phrase string) ([]Message, error)
|
|||
func (u *User) openMessageLog() {
|
||||
var err error
|
||||
|
||||
u.messageLog, err = bolt.Open(path.Join(appDir, "logs", u.UUID+"_log"), 0600, nil)
|
||||
u.messageLog, err = bolt.Open(path.Join(AppDir, "logs", u.UUID+"_log"), 0600, nil)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -315,7 +315,7 @@ func (u *User) openMessageLog() {
|
|||
return nil
|
||||
})
|
||||
|
||||
indexPath := path.Join(appDir, "logs", u.UUID+"_index")
|
||||
indexPath := path.Join(AppDir, "logs", u.UUID+"_index")
|
||||
u.messageIndex, err = bleve.Open(indexPath)
|
||||
if err == bleve.ErrorIndexPathDoesNotExist {
|
||||
mapping := bleve.NewIndexMapping()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue