Output sub command helps
(command string)
| 153 | |
| 154 | //Output sub command helps |
| 155 | func (gohanClientCLI *GohanClientCLI) outputSubCommands(command string) (string, error) { |
| 156 | schemas, err := gohanClientCLI.getSchemas() |
| 157 | command = strings.TrimSpace(command) |
| 158 | buf := new(bytes.Buffer) |
| 159 | if err != nil { |
| 160 | return "", err |
| 161 | } |
| 162 | //Output schema specific help |
| 163 | for _, schemaForTemplate := range schemas { |
| 164 | if command == schemaForTemplate.ID { |
| 165 | schema.SortActions(schemaForTemplate) |
| 166 | tmpl, _ := template.New("schema").Parse(schemaTemplate) |
| 167 | tmpl.Execute(buf, schemaForTemplate) |
| 168 | return buf.String(), nil |
| 169 | } |
| 170 | } |
| 171 | |
| 172 | tmpl, _ := template.New("schema").Parse(schemaListTemplate) |
| 173 | if command != "" { |
| 174 | buf.WriteString("Command not found") |
| 175 | return buf.String(), nil |
| 176 | } |
| 177 | for _, schema := range schemas { |
| 178 | tmpl.Execute(buf, schema) |
| 179 | } |
| 180 | return buf.String(), nil |
| 181 | } |
| 182 | |
| 183 | func outputCustomCommands(schema *schema.Schema, action *schema.Action) (string, error) { |
| 184 | entry := ActionTemplateEntry{schema, action} |
no test coverage detected