-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.go
More file actions
59 lines (54 loc) · 1.29 KB
/
Copy pathview.go
File metadata and controls
59 lines (54 loc) · 1.29 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import "fmt"
// Get the host's name from the user.
func getHostNameFromUser() string {
hostName := ""
var err error
var code int
// Make sure that the hostname is set.
for err != nil || hostName == "" {
fmt.Println("Enter the HostName:")
code, err = fmt.Scanln(&hostName)
if err != nil {
fmt.Printf("Got code %d, error %s", code, err)
}
}
return hostName
}
// Get the host's user from the user.
func getUserFromUser() string {
user := ""
var err error
var code int
// Make sure the input is valid.
for err != nil || user == "" {
fmt.Println("Enter the user:")
code, err = fmt.Scanln(&user)
if err != nil {
fmt.Printf("Got code %d, error %s", code, err)
}
}
return user
}
// Get the host's name from the user.
func getConfigName() string {
configName := ""
var err error
var code int
// Make sure the input is valid.
for err != nil || configName == "" {
fmt.Println("Enter the config name:")
code, err = fmt.Scanln(&configName)
if err != nil {
fmt.Printf("Got code %d, error %s", code, err)
}
}
return configName
}
// Gets all host information from the user and returns the host.
func getHostFromUser() *host {
configName := getConfigName()
hostName := getHostNameFromUser()
user := getUserFromUser()
return newHost(configName, hostName, user)
}