(f *cmdutil.Factory, runF func(*CreditsOptions) error)
| 69 | } |
| 70 | |
| 71 | func NewCmdRepoCredits(f *cmdutil.Factory, runF func(*CreditsOptions) error) *cobra.Command { |
| 72 | opts := &CreditsOptions{ |
| 73 | HttpClient: f.HttpClient, |
| 74 | BaseRepo: f.BaseRepo, |
| 75 | IO: f.IOStreams, |
| 76 | } |
| 77 | |
| 78 | cmd := &cobra.Command{ |
| 79 | Use: "credits [<repository>]", |
| 80 | Short: "View credits for a repository", |
| 81 | Example: heredoc.Doc(` |
| 82 | # View credits for the current repository |
| 83 | $ gh repo credits |
| 84 | |
| 85 | # View credits for a specific repository |
| 86 | $ gh repo credits cool/repo |
| 87 | |
| 88 | # Print a non-animated thank you |
| 89 | $ gh repo credits -s |
| 90 | |
| 91 | # Pipe to just print the contributors, one per line |
| 92 | $ gh repo credits | cat |
| 93 | `), |
| 94 | Args: cobra.MaximumNArgs(1), |
| 95 | RunE: func(cmd *cobra.Command, args []string) error { |
| 96 | if len(args) > 0 { |
| 97 | opts.Repository = args[0] |
| 98 | } |
| 99 | |
| 100 | if runF != nil { |
| 101 | return runF(opts) |
| 102 | } |
| 103 | |
| 104 | return creditsRun(opts) |
| 105 | }, |
| 106 | Hidden: true, |
| 107 | } |
| 108 | |
| 109 | cmd.Flags().BoolVarP(&opts.Static, "static", "s", false, "Print a static version of the credits") |
| 110 | |
| 111 | return cmd |
| 112 | } |
| 113 | |
| 114 | func creditsRun(opts *CreditsOptions) error { |
| 115 | isWindows := runtime.GOOS == "windows" |
nothing calls this directly
no test coverage detected