(cfg *action.Configuration, out io.Writer)
| 35 | ` |
| 36 | |
| 37 | func newGetHooksCmd(cfg *action.Configuration, out io.Writer) *cobra.Command { |
| 38 | client := action.NewGet(cfg) |
| 39 | |
| 40 | cmd := &cobra.Command{ |
| 41 | Use: "hooks RELEASE_NAME", |
| 42 | Short: "download all hooks for a named release", |
| 43 | Long: getHooksHelp, |
| 44 | Args: require.ExactArgs(1), |
| 45 | ValidArgsFunction: func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 46 | if len(args) != 0 { |
| 47 | return noMoreArgsComp() |
| 48 | } |
| 49 | return compListReleases(toComplete, args, cfg) |
| 50 | }, |
| 51 | RunE: func(_ *cobra.Command, args []string) error { |
| 52 | res, err := client.Run(args[0]) |
| 53 | if err != nil { |
| 54 | return err |
| 55 | } |
| 56 | rac, err := release.NewAccessor(res) |
| 57 | if err != nil { |
| 58 | return err |
| 59 | } |
| 60 | for _, hook := range rac.Hooks() { |
| 61 | hac, err := release.NewHookAccessor(hook) |
| 62 | if err != nil { |
| 63 | return err |
| 64 | } |
| 65 | fmt.Fprintf(out, "---\n# Source: %s\n%s\n", hac.Path(), hac.Manifest()) |
| 66 | } |
| 67 | return nil |
| 68 | }, |
| 69 | } |
| 70 | |
| 71 | cmd.Flags().IntVar(&client.Version, "revision", 0, "get the named release with revision") |
| 72 | err := cmd.RegisterFlagCompletionFunc("revision", func(_ *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { |
| 73 | if len(args) == 1 { |
| 74 | return compListRevisions(toComplete, cfg, args[0]) |
| 75 | } |
| 76 | return nil, cobra.ShellCompDirectiveNoFileComp |
| 77 | }) |
| 78 | |
| 79 | if err != nil { |
| 80 | log.Fatal(err) |
| 81 | } |
| 82 | |
| 83 | return cmd |
| 84 | } |
no test coverage detected
searching dependent graphs…