Skip to content

Commit a48ccf5

Browse files
committed
readme更新
1 parent a330be8 commit a48ccf5

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,39 @@ func main() {
5858
fmt.Println(gscp.Parse(s))
5959
}
6060
```
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:\src\smp> go run .\cmd\main.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+
6194
## License
6295
Copyright (c) 2023 harakeishi
6396

0 commit comments

Comments
 (0)