-
Notifications
You must be signed in to change notification settings - Fork 1
/
print_env.go
45 lines (36 loc) · 978 Bytes
/
print_env.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
package cli // import "github.com/MOZGIII/dphx/internal/dphx/cli"
import (
"fmt"
"github.com/MOZGIII/dphx/internal/dphx/config"
)
// PrintEnv prints current environment.
func PrintEnv(appConfig *config.App) {
fmt.Printf("ENV:\n")
printAppConfig(appConfig)
fmt.Printf("\n")
}
func printAppConfig(cfg *config.App) {
print("SSH Server Address", cfg.SSH.ServerAddr)
print("SSH Username", cfg.SSH.Username)
if cfg.SSH.Password == "" {
print("SSH Password", "<empty>")
} else {
print("SSH Password", "[hidden]")
}
printArray("SSH Public Keys", cfg.SSH.PublicKeys)
print("SSH Agent Address", cfg.SSH.AgentAddr)
print("SOCKS5 Server Address", cfg.LocalAddr)
}
func print(key, value string) {
fmt.Printf(" %-24s %s\n", key+":", value)
}
func printArray(key string, values []string) {
fmt.Printf(" %-24s\n", key+":")
if len(values) == 0 {
fmt.Printf(" <empty>\n")
} else {
for _, value := range values {
fmt.Printf(" - %s\n", value)
}
}
}