feat: get handlers return object slices
This commit is contained in:
10
cmd/verbs.go
10
cmd/verbs.go
@ -33,8 +33,8 @@ var verbs = []VerbItem{
|
||||
return fmt.Errorf("resource does not support GET")
|
||||
}
|
||||
|
||||
// Get item
|
||||
item, err := h.Get(ctx, params)
|
||||
// Get items
|
||||
items, err := h.Get(ctx, params)
|
||||
if err != nil {
|
||||
return fmt.Errorf("retrieving item failed: %w", err)
|
||||
}
|
||||
@ -46,7 +46,7 @@ var verbs = []VerbItem{
|
||||
}
|
||||
|
||||
// Format and output
|
||||
formatted, err := formatter.Format(item)
|
||||
formatted, err := formatter.Format(items)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to format output: %w", err)
|
||||
}
|
||||
@ -61,8 +61,6 @@ var verbs = []VerbItem{
|
||||
}
|
||||
|
||||
func getVerbs(ctx context.Context, config *AppConfig) (commands []*cobra.Command) {
|
||||
logger := jlog.FromContext(ctx)
|
||||
|
||||
for _, v := range verbs {
|
||||
verbCommand := &cobra.Command{
|
||||
Use: strings.ToLower(string(v.Name)),
|
||||
@ -115,8 +113,6 @@ func getVerbs(ctx context.Context, config *AppConfig) (commands []*cobra.Command
|
||||
)
|
||||
}
|
||||
verbCommand.AddCommand(resourceCommand)
|
||||
|
||||
logger.Debug(fmt.Sprintf("Registered %s %s", strings.ToUpper(string(v.Name)), r.Name))
|
||||
}
|
||||
|
||||
commands = append(commands, verbCommand)
|
||||
|
||||
Reference in New Issue
Block a user