MCPcopy
hub / github.com/cli/cli / NewCmdRepoCredits

Function NewCmdRepoCredits

pkg/cmd/repo/credits/credits.go:71–112  ·  view source on GitHub ↗
(f *cmdutil.Factory, runF func(*CreditsOptions) error)

Source from the content-addressed store, hash-verified

69}
70
71func 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
114func creditsRun(opts *CreditsOptions) error {
115 isWindows := runtime.GOOS == "windows"

Callers

nothing calls this directly

Calls 1

creditsRunFunction · 0.85

Tested by

no test coverage detected