forked from hrishiksh/hash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
43 lines (35 loc) · 718 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"errors"
"log"
"os"
"path/filepath"
tea "github.com/charmbracelet/bubbletea"
"github.com/hrishikesh/hash/database"
)
var configDir string
func main() {
var err error
userConfigDir, err := os.UserConfigDir()
if err != nil {
log.Fatal(err)
return
}
// creating hash directory in user cofig directory
configDir = filepath.Join(userConfigDir, "hash")
err = os.Mkdir(configDir, 0750)
if err != nil && !errors.Is(err, os.ErrExist) {
log.Fatal(err)
return
}
err = database.InitDB(filepath.Join(configDir, "password.db"))
if err != nil {
log.Fatal(err)
return
}
p := tea.NewProgram(initialModel())
if _, err := p.Run(); err != nil {
log.Fatal(err)
return
}
}