File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -11,5 +11,7 @@ require (
1111require (
1212 github.com/alecthomas/repr v0.4.0 // indirect
1313 github.com/hexops/gotextdiff v1.0.3 // indirect
14+ github.com/swaggest/jsonschema-go v0.3.78 // indirect
15+ github.com/swaggest/refl v1.4.0 // indirect
1416 golang.org/x/sys v0.35.0 // indirect
1517)
Original file line number Diff line number Diff line change @@ -6,6 +6,10 @@ github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc
66github.com/alecthomas/repr v0.4.0 /go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4 =
77github.com/hexops/gotextdiff v1.0.3 h1:gitA9+qJrrTCsiCl7+kh75nPqQt1cx4ZkudSTLoUqJM =
88github.com/hexops/gotextdiff v1.0.3 /go.mod h1:pSWU5MAI3yDq+fZBTazCSJysOMbxWL1BSow5/V2vxeg =
9+ github.com/swaggest/jsonschema-go v0.3.78 h1:5+YFQrLxOR8z6CHvgtZc42WRy/Q9zRQQ4HoAxlinlHw =
10+ github.com/swaggest/jsonschema-go v0.3.78 /go.mod h1:4nniXBuE+FIGkOGuidjOINMH7OEqZK3HCSbfDuLRI0g =
11+ github.com/swaggest/refl v1.4.0 h1:CftOSdTqRqs100xpFOT/Rifss5xBV/CT0S/FN60Xe9k =
12+ github.com/swaggest/refl v1.4.0 /go.mod h1:4uUVFVfPJ0NSX9FPwMPspeHos9wPFlCMGoPRllUbpvA =
913golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4 =
1014golang.org/x/crypto v0.41.0 /go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc =
1115golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI =
Original file line number Diff line number Diff line change @@ -10,21 +10,21 @@ import (
1010type cli struct {
1111 ListenAddr string `help:"Address to listen on" default:":2222"`
1212 Config string `help:"Path to JSON config file"`
13+
14+ Serve serveCmd `cmd:"" default:"1" help:"Start the server"`
15+ JSONSchema jsonschemaCmd `cmd:"" name:"jsonschema" help:"Print config JSON schema"`
1316}
1417
15- func (c * cli ) Run () error {
18+ type serveCmd struct {}
19+
20+ func (s * serveCmd ) Run (c * cli ) error {
1621 config , err := sshgate .Open (c .Config )
1722 if err != nil {
1823 return err
1924 }
2025
2126 server := sshgate .New (config , c .ListenAddr )
22-
23- if err := server .ListenAndServe (context .Background ()); err != nil {
24- return err
25- }
26-
27- return nil
27+ return server .ListenAndServe (context .Background ())
2828}
2929
3030func Execute () {
Original file line number Diff line number Diff line change 1+ package cmd
2+
3+ import (
4+ "encoding/json"
5+ "log"
6+ "os"
7+
8+ "github.com/cedws/sshgate/pkg/sshgate"
9+ "github.com/swaggest/jsonschema-go"
10+ )
11+
12+ type jsonschemaCmd struct {}
13+
14+ func (j * jsonschemaCmd ) Run () error {
15+ reflector := jsonschema.Reflector {}
16+ schema , err := reflector .Reflect (sshgate.Config {})
17+ if err != nil {
18+ log .Fatal (err )
19+ }
20+
21+ enc := json .NewEncoder (os .Stdout )
22+ enc .SetIndent ("" , " " )
23+
24+ return enc .Encode (schema )
25+ }
You can’t perform that action at this time.
0 commit comments