MCPcopy Create free account
hub / github.com/cloudwan/gohan / outputSubCommands

Method outputSubCommands

cli/client/client.go:155–181  ·  view source on GitHub ↗

Output sub command helps

(command string)

Source from the content-addressed store, hash-verified

153
154//Output sub command helps
155func (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
183func outputCustomCommands(schema *schema.Schema, action *schema.Action) (string, error) {
184 entry := ActionTemplateEntry{schema, action}

Callers 1

ExecuteCommandMethod · 0.95

Calls 3

getSchemasMethod · 0.95
ParseMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected