MCPcopy
hub / github.com/dagger/dagger / String

Method String

cmd/dagger/shell_help.go:217–250  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

215}
216
217func (d ShellDoc) String() string {
218 width := getViewWidth()
219
220 sb := new(strings.Builder)
221 for i, grp := range d.Groups {
222 body := grp.Body
223
224 if grp.Title != "" {
225 sb.WriteString(indent.String(toUpperBold(grp.Title), grp.Indent))
226 sb.WriteString("\n")
227
228 // Indent body if there's a title
229 var i uint
230 if !strings.HasPrefix(body, strings.Repeat(" ", int(helpIndent))) {
231 i = helpIndent + grp.Indent
232 } else if grp.Indent > 0 && !strings.HasPrefix(body, strings.Repeat(" ", int(helpIndent+grp.Indent))) {
233 i = grp.Indent
234 }
235 if i > 0 {
236 wrapped := wordwrap.String(grp.Body, width-int(i))
237 body = indent.String(wrapped, i)
238 }
239 }
240 sb.WriteString(body)
241 if !strings.HasSuffix(body, "\n") {
242 sb.WriteString("\n")
243 }
244 // Extra new line between groups
245 if i < len(d.Groups)-1 {
246 sb.WriteString("\n")
247 }
248 }
249 return sb.String()
250}
251
252// FunctionUseLine returns the usage line fine for a function
253func (h *shellCallHandler) FunctionUseLine(md *moduleDef, fn *modFunction) string {

Callers 6

defaultHelpMethod · 0.95
MainHelpMethod · 0.95
TypesHelpMethod · 0.95
ModuleDocMethod · 0.95
FunctionDocMethod · 0.95
shellTypeDocFunction · 0.95

Calls 3

getViewWidthFunction · 0.85
toUpperBoldFunction · 0.85
StringMethod · 0.65

Tested by

no test coverage detected