/
get_entry_status.go
51 lines (43 loc) · 1.1 KB
/
get_entry_status.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
46
47
48
49
50
51
package cli
import (
"context"
msg "github.com/ArthurHlt/messages"
gslbsvc "github.com/orange-cloudfoundry/gsloc-go-sdk/gsloc/services/gslb/v1"
)
type GetEntryStatus struct {
FQDN *FQDN `positional-args:"true" positional-arg-name:"'fqdn'" required:"true"`
Json bool `short:"j" long:"json" description:"Format in json instead of human table readable."`
client gslbsvc.GSLBClient
}
func (c *GetEntryStatus) SetClient(client gslbsvc.GSLBClient) {
c.client = client
}
var getEntryStatus GetEntryStatus
func (c *GetEntryStatus) Execute([]string) error {
msg.UseStderr()
msg.Infof("Entry %s configuration", msg.Cyan(c.FQDN))
msg.Printf("━━━━━\n")
msg.UseStdout()
entResp, err := c.client.GetEntryStatus(context.Background(), &gslbsvc.GetEntryStatusRequest{
Fqdn: c.FQDN.String(),
})
if err != nil {
return err
}
if c.Json {
return PrintProtoJson(entResp)
}
return PrintProtoHuman(entResp)
}
func init() {
desc := "Get entry with status."
cmd, err := parser.AddCommand(
"entry-status",
desc,
desc,
&getEntryStatus)
if err != nil {
panic(err)
}
cmd.Aliases = []string{"es"}
}