MCPcopy Create free account
hub / github.com/cli/cli / renderGitIgnore

Function renderGitIgnore

pkg/cmd/repo/gitignore/view/view.go:102–118  ·  view source on GitHub ↗
(licenseTemplate *api.GitIgnore, opts *ViewOptions)

Source from the content-addressed store, hash-verified

100}
101
102func renderGitIgnore(licenseTemplate *api.GitIgnore, opts *ViewOptions) error {
103 // I wanted to render this in a markdown code block and benefit
104 // from .gitignore syntax highlighting. But, the upstream syntax highlighter
105 // does not currently support .gitignore.
106 // So, I just add a newline and print the content as is instead.
107 // Ref: https://github.com/alecthomas/chroma/pull/755
108 var out strings.Builder
109 if opts.IO.IsStdoutTTY() {
110 out.WriteString("\n")
111 }
112 out.WriteString(licenseTemplate.Source)
113 _, err := opts.IO.Out.Write([]byte(out.String()))
114 if err != nil {
115 return err
116 }
117 return nil
118}

Callers 1

viewRunFunction · 0.85

Calls 3

IsStdoutTTYMethod · 0.80
WriteMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected