-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
70 lines (58 loc) · 1.01 KB
/
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
package main
import (
"fmt"
)
const (
dateTimeFormat string = "2006-01-02T15:04:05-0700"
)
const (
vaultDirectory = "./SeraphVaults/"
vaultAlreadyExistsError = "vault already exists"
)
// Step 0
const (
exit int = iota
openVault
newVault
testVault
)
func check(e error) {
if e != nil {
panic(e)
}
}
type Context struct {
hashedPassword string
vault *vault
}
func main() {
var app *Context
clearScreen()
initVaultDirectory()
// TODO: Non-interactive handling
// flags := getFlags()
for {
index, _, _ := promptForSelect("Choose", []string{"Exit", "Open Vault", "New Vault"})
if index == exit {
return
}
// Re-init at every cycle
app = &Context{}
if index == openVault {
// Opening existing vault
err := chooseVault(app)
if err != nil {
continue
}
openedVaultHandling(app)
} else if index == newVault {
// Create new vault
err := newVaultHandling(app)
if err != nil {
fmt.Println(err)
return
}
openedVaultHandling(app)
}
}
}