MCPcopy Create free account
hub / github.com/basecamp/hey-cli / newCommandsCommand

Function newCommandsCommand

internal/cmd/commands.go:10–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8)
9
10func newCommandsCommand() *cobra.Command {
11 return &cobra.Command{
12 Use: "commands",
13 Short: "List all available commands",
14 RunE: func(cmd *cobra.Command, args []string) error {
15 catalog := walkCommands(cmd.Root(), "")
16
17 if writer.IsStyled() {
18 table := newTable(cmd.OutOrStdout())
19 table.addRow([]string{"Command", "Description"})
20 for _, entry := range catalog {
21 path, _ := entry["path"].(string)
22 short, _ := entry["short"].(string)
23 table.addRow([]string{path, short})
24 }
25 table.print()
26 return nil
27 }
28
29 return writeOK(catalog,
30 output.WithSummary("Available commands"),
31 )
32 },
33 }
34}
35
36func walkCommands(cmd *cobra.Command, prefix string) []map[string]any {
37 var result []map[string]any

Callers 1

newRootCmdFunction · 0.85

Calls 7

WithSummaryFunction · 0.92
walkCommandsFunction · 0.85
newTableFunction · 0.85
writeOKFunction · 0.85
IsStyledMethod · 0.80
addRowMethod · 0.80
printMethod · 0.80

Tested by

no test coverage detected