File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -58,6 +58,39 @@ func main() {
58
58
fmt.Println (gscp.Parse (s))
59
59
}
60
60
```
61
+
62
+ Obtains information on the specified host and the specified options.
63
+
64
+ ``` go
65
+ package main
66
+
67
+ import (
68
+ " fmt"
69
+ " github.com/harakeishi/gscp"
70
+ )
71
+
72
+ func main () {
73
+ // Specify path
74
+ path := gscp.Path (" ./testData/test1_config" )
75
+ // Load config.
76
+ s , _ := gscp.LoadConfig (path)
77
+ // Parse config.
78
+ hosts , _ := gscp.Parse (s)
79
+ // Obtain information on the specified host
80
+ host := hosts.FindHost (" testhost" )
81
+ fmt.Printf (" %+v \n " , host)
82
+ // Obtain information on specified options
83
+ hostname := host.FindOption (" HostName" ).Value
84
+ fmt.Printf (" %+v \n " , hostname)
85
+ }
86
+ ```
87
+
88
+ ``` sh
89
+ PS C:\s rc\s mp> go run .\c md\m ain.go
90
+ {Name:testhost Options:[{Name:HostName Value:192.0.2.1} {Name:User Value:myuser} {Name:IdentityFile Value:~ /.ssh/id_rsa} {Name:ServerAliveInterval Value:60}]}
91
+ 192.0.2.1
92
+ ```
93
+
61
94
## License
62
95
Copyright (c) 2023 harakeishi
63
96
You can’t perform that action at this time.
0 commit comments