-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.go
More file actions
45 lines (40 loc) · 1.05 KB
/
Copy pathmain.go
File metadata and controls
45 lines (40 loc) · 1.05 KB
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
package main
import (
"fmt"
"strings"
)
var asciiTitle string = `
_____ _____ _ _
/ ____| / ____| | | | |
| | __ ___ | | ___ _ __ | |_ __ _ ___| |_ ___
| | |_ |/ _ \ | | / _ \| '_ \| __/ _' |/ __| __/ __|
| |__| | (_) | | |___| (_) | | | | || (_| | (__| |_\__ \
\_____ |\___/ \_____\___/|_| |_|\__\__,_|\___|\__|___/`
var contacts []Contact
var quit bool = false
func main() {
readContactsFromFile()
for !quit {
clearScreen()
printHeader("")
printMenu()
userChoice, err := getValidationInput(InputTypeMenuItem)
if err != nil {
errorString := err.Error()
fmt.Println()
fmt.Println(strings.Title(errorString))
fmt.Println("Press enter to try again.")
getInput()
} else {
option := menuItems[userChoice]
runOption(option)
}
}
}
// runOption takes in a option and, clears the screen, prints the header with
// the option's description and then runs its function
func runOption(o Option) {
clearScreen()
printHeader(o.Description)
o.Function()
}