in cli/cmd/show.go [31:77]
func show(cmd *cobra.Command, args []string) {
if Project == "" {
altProjectSources()
}
req, err := NewRequest()
if err != nil {
fmt.Printf("Error: %s", err)
return
}
resp, err := req.
Get(fmt.Sprintf("%s/%s", baseURL(), args[0]))
if err != nil {
fmt.Printf("Error: %s", err)
fmt.Println()
return
}
if resp.IsSuccess() {
if Out == JsonO {
var pretty bytes.Buffer
err = json.Indent(&pretty, resp.Body(), "", "\t")
if err != nil {
fmt.Printf("Failed indent json body: %s", err)
return
}
fmt.Println(pretty.String())
return
}
var state State
err = json.Unmarshal(resp.Body(), &state)
if err != nil {
fmt.Printf("Failed unmarshal json body: %s", err)
return
}
tableFmtState(state)
return
}
if resp.StatusCode() == 404 {
fmt.Printf("Error: State \"%s\" not found", args[0])
return
}
fmt.Printf("Error: %s", resp.Status())
return
}