(deps commandDeps)
| 74 | } |
| 75 | |
| 76 | func newHooksInfoCommand(deps commandDeps) *cobra.Command { |
| 77 | var workspace string |
| 78 | |
| 79 | cmd := &cobra.Command{ |
| 80 | Use: hooksInfoNameValue, |
| 81 | Short: "Show detailed information for one or more hooks by name", |
| 82 | Args: exactOneNonBlankArg(), |
| 83 | RunE: func(cmd *cobra.Command, args []string) error { |
| 84 | client, err := clientFromDeps(deps) |
| 85 | if err != nil { |
| 86 | return err |
| 87 | } |
| 88 | |
| 89 | hooks, err := client.HookCatalog(cmd.Context(), HookCatalogQuery{Workspace: workspace}) |
| 90 | if err != nil { |
| 91 | return err |
| 92 | } |
| 93 | |
| 94 | name := strings.TrimSpace(args[0]) |
| 95 | matches := make([]HookCatalogRecord, 0) |
| 96 | for _, hook := range hooks { |
| 97 | if strings.TrimSpace(hook.Name) == name { |
| 98 | matches = append(matches, hook) |
| 99 | } |
| 100 | } |
| 101 | if len(matches) == 0 { |
| 102 | return fmt.Errorf("cli: no hooks named %q found", name) |
| 103 | } |
| 104 | |
| 105 | return writeCommandOutput(cmd, hookInfoBundle(matches)) |
| 106 | }, |
| 107 | } |
| 108 | |
| 109 | cmd.Flags().StringVar(&workspace, "workspace", "", "Resolve hooks in one workspace context") |
| 110 | return cmd |
| 111 | } |
| 112 | |
| 113 | func newHooksEventsCommand(deps commandDeps) *cobra.Command { |
| 114 | var query HookEventsQuery |
no test coverage detected