-
Notifications
You must be signed in to change notification settings - Fork 0
/
oxiterm.go
66 lines (59 loc) · 1.7 KB
/
oxiterm.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
package main
import (
"fmt"
"github.com/oxipass/oxilib"
"github.com/rivo/tview"
"log"
"os"
"os/user"
)
var app = tview.NewApplication()
var dbFile string
var oxi *oxilib.StorageSingleton // Oxi Library active instance
// TODO: URGENT! Use oxilib multilingual localization
// TODO: Add interactive and non-interactive mode with flags
// TODO: Add the flag for configuration file
// TODO: Add the flag for storage folder (can maintain and test many databases)
// TODO: Add the flag to backup the data
// TODO: Add the flag to import the data (backup, json, NS Wallet, LastPass, 1Password)
// TODO: Add the flag to export the data
// TODO: Add the flag to generate human readable PDF file for printing
// TODO:
func main() {
fmt.Println(cAppName, cVersion)
usr, err := user.Current()
if err != nil {
log.Fatal(err)
}
appFolder := usr.HomeDir + "/" + cAppFolder
dbFile = appFolder + "/" + cDbFile
if _, err := os.Stat(appFolder); os.IsNotExist(err) {
err := os.MkdirAll(appFolder, os.ModePerm)
if err != nil {
log.Fatal("Initiation error: " + err.Error())
return
}
}
oxi = oxilib.GetInstance()
log.Println("OxiPass is initiating... ")
log.Println("Path to database: " + dbFile)
err = oxi.Open(dbFile)
if err != nil {
log.Fatal("Initiation error: " + err.Error())
return
}
isNew := oxi.IsNew()
log.Println("App started in interactive mode")
if isNew {
log.Println("OxiPass first time start, performing secure database initialization")
NavToRegistration()
} else {
log.Println("Database processed and checked, proceeding to the interactive login screen")
NavToLogin()
}
app.EnableMouse(true)
if err := app.Run(); err != nil {
log.Fatalln(err)
}
log.Println("App stopped, bye")
}