MCPcopy
hub / github.com/larksuite/cli / Format

Method Format

internal/cmdutil/dryrun.go:133–196  ·  view source on GitHub ↗

Format renders the dry-run output as plain text for AI/human consumption.

()

Source from the content-addressed store, hash-verified

131
132// Format renders the dry-run output as plain text for AI/human consumption.
133func (d *DryRunAPI) Format() string {
134 var b strings.Builder
135
136 if d.desc != "" {
137 b.WriteString("# ")
138 b.WriteString(d.desc)
139 b.WriteByte('\n')
140 }
141
142 for i, c := range d.calls {
143 if i > 0 || d.desc != "" {
144 b.WriteByte('\n')
145 }
146 if c.Desc != "" {
147 b.WriteString("# ")
148 b.WriteString(c.Desc)
149 b.WriteByte('\n')
150 }
151
152 u := d.resolveURL(c.URL)
153 if len(c.Params) > 0 {
154 u += "?" + encodeParams(c.Params)
155 }
156
157 method := c.Method
158 if method == "" {
159 method = "GET"
160 }
161 b.WriteString(method)
162 b.WriteByte(' ')
163 b.WriteString(u)
164 b.WriteByte('\n')
165
166 if !util.IsNil(c.Body) {
167 j, _ := json.Marshal(c.Body)
168 b.WriteString(" ")
169 b.Write(j)
170 b.WriteByte('\n')
171 }
172 }
173
174 if len(d.calls) == 0 && len(d.extra) > 0 {
175 if d.desc != "" {
176 b.WriteByte('\n')
177 }
178 keys := make([]string, 0, len(d.extra))
179 for k := range d.extra {
180 keys = append(keys, k)
181 }
182 sort.Strings(keys)
183 for _, k := range keys {
184 sv := dryRunFormatValue(d.extra[k])
185 if sv == "" {
186 continue
187 }
188 b.WriteString(k)
189 b.WriteString(": ")
190 b.WriteString(sv)

Callers 15

PrintDryRunWithFileFunction · 0.95
PrintDryRunFunction · 0.95
TestDryRunAPI_SingleGETFunction · 0.80
TestDryRunAPI_WithParamsFunction · 0.80
TestDryRunAPI_WithBodyFunction · 0.80
TestDryRunAPI_ResolveURLFunction · 0.80
SyncSkillsFunction · 0.80
fallbackFullInstallFunction · 0.80

Calls 6

resolveURLMethod · 0.95
IsNilFunction · 0.92
encodeParamsFunction · 0.85
dryRunFormatValueFunction · 0.85
WriteMethod · 0.65
StringMethod · 0.45