(s *schema.Schema)
| 82 | } |
| 83 | |
| 84 | func (gohanClientCLI *GohanClientCLI) getGetCommand(s *schema.Schema) gohanCommand { |
| 85 | return gohanCommand{ |
| 86 | Name: fmt.Sprintf("%s show", s.ID), |
| 87 | Schema: s, |
| 88 | Action: func(args []string) (string, error) { |
| 89 | if len(args) < 1 { |
| 90 | return "", fmt.Errorf("Wrong number of arguments") |
| 91 | } |
| 92 | _, err := gohanClientCLI.handleArguments(args[:len(args)-1], s) |
| 93 | if err != nil { |
| 94 | return "", err |
| 95 | } |
| 96 | id, err := gohanClientCLI.getResourceID(s, args[len(args)-1]) |
| 97 | if err != nil { |
| 98 | return "", err |
| 99 | } |
| 100 | url := fmt.Sprintf("%s%s/%s%s", gohanClientCLI.opts.gohanEndpointURL, s.URL, id, gohanClientCLI.getFieldsParam(true)) |
| 101 | result, err := gohanClientCLI.request("GET", url, nil) |
| 102 | if err != nil { |
| 103 | return "", err |
| 104 | } |
| 105 | buffer := bytes.NewBufferString("") |
| 106 | buffer.WriteString(gohanClientCLI.formatOutput(s, result)) |
| 107 | for _, childSchema := range gohanClientCLI.schemas { |
| 108 | if s.ID == childSchema.Parent { |
| 109 | buffer.WriteString("\n") |
| 110 | buffer.WriteString(childSchema.Title) |
| 111 | buffer.WriteString("\n") |
| 112 | parentSchemaPropertyID := childSchema.ParentSchemaPropertyID() |
| 113 | url := fmt.Sprintf("%s%s?%s=%s%s", gohanClientCLI.opts.gohanEndpointURL, childSchema.URL, parentSchemaPropertyID, id, gohanClientCLI.getFieldsParam(false)) |
| 114 | result, err := gohanClientCLI.request("GET", url, nil) |
| 115 | if err != nil { |
| 116 | return "", err |
| 117 | } |
| 118 | buffer.WriteString(gohanClientCLI.formatOutput(childSchema, result)) |
| 119 | } |
| 120 | } |
| 121 | return buffer.String(), nil |
| 122 | }, |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | func (gohanClientCLI *GohanClientCLI) getPostCommand(s *schema.Schema) gohanCommand { |
| 127 | return gohanCommand{ |
no test coverage detected