-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
51 lines (38 loc) · 971 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
44
45
46
47
48
49
50
51
package main
import (
"flag"
"fmt"
"os"
"strings"
controllers "Secure-Vault-CLI/controllers"
models "Secure-Vault-CLI/models"
Colors "Secure-Vault-CLI/utils"
"github.com/manifoldco/promptui"
)
func main() {
var res models.ResponseModel
Colors.Colorize(Colors.Yellow(), "Welcome to Secret Vault\n")
loginCmd := flag.NewFlagSet("login", flag.ExitOnError)
signupCmd := flag.NewFlagSet("signup", flag.ExitOnError)
prompt := promptui.Select{
Label: "Select an Option",
Items: []string{"Login", "Signup"},
}
if len(os.Args) < 2 {
_, res.Result, res.Err = prompt.Run()
if res.Err != nil {
fmt.Printf("Prompt failed %v\n", res.Err)
os.Exit(1)
}
} else {
res.Result = os.Args[1]
}
switch strings.ToLower(res.Result) {
case "login":
controllers.HandleLogin(loginCmd)
case "signup":
controllers.HandleSignup(signupCmd)
default: // if we don't understand the input
Colors.Colorize(Colors.Red(), "Enter a valid command")
}
}