MCPcopy Create free account
hub / github.com/openclaw/gogcli / BuildRequests

Function BuildRequests

internal/docsformat/format.go:103–155  ·  view source on GitHub ↗
(options Options, start, end int64, tabID string)

Source from the content-addressed store, hash-verified

101}
102
103func BuildRequests(options Options, start, end int64, tabID string) ([]*docs.Request, error) {
104 if start < 0 || end <= start {
105 return nil, invalidf("invalid format range: %d..%d", start, end)
106 }
107
108 textReq, hasText, err := buildTextStyleRequest(options, start, end, tabID)
109 if err != nil {
110 return nil, err
111 }
112
113 paragraphStart, paragraphEnd := start, end
114
115 hasPostBulletRange := options.PostBulletParagraphStart > 0 && options.PostBulletParagraphEnd > options.PostBulletParagraphStart
116 if hasPostBulletRange {
117 paragraphStart = options.PostBulletParagraphStart
118 paragraphEnd = options.PostBulletParagraphEnd
119 }
120
121 paragraphReq, hasParagraph, err := buildParagraphStyleRequest(options, paragraphStart, paragraphEnd, tabID)
122 if err != nil {
123 return nil, err
124 }
125
126 bulletReq, hasBullets, err := buildParagraphBulletsRequest(options, start, end, tabID)
127 if err != nil {
128 return nil, err
129 }
130
131 requests := make([]*docs.Request, 0, 3)
132 if hasText {
133 requests = append(requests, textReq)
134 }
135
136 // Removing bullets preserves list nesting by adding paragraph indentation.
137 // Apply explicit paragraph controls afterward so the caller's values win.
138 if hasBullets && (options.ClearBullets || hasPostBulletRange) {
139 requests = append(requests, bulletReq)
140 }
141
142 if hasParagraph {
143 requests = append(requests, paragraphReq)
144 }
145
146 if hasBullets && !options.ClearBullets && !hasPostBulletRange {
147 requests = append(requests, bulletReq)
148 }
149
150 if len(requests) == 0 {
151 return nil, ValidationError("no formatting flags provided")
152 }
153
154 return requests, nil
155}
156
157func buildTextStyleRequest(options Options, start, end int64, tabID string) (*docs.Request, bool, error) {
158 style := &docs.TextStyle{}

Calls 5

invalidfFunction · 0.70
buildTextStyleRequestFunction · 0.70
ValidationErrorTypeAlias · 0.70