MCPcopy
hub / github.com/cli/cli / getBody

Function getBody

pkg/cmd/variable/set/set.go:266–286  ·  view source on GitHub ↗
(opts *SetOptions)

Source from the content-addressed store, hash-verified

264}
265
266func getBody(opts *SetOptions) (string, error) {
267 if opts.Body != "" {
268 return opts.Body, nil
269 }
270
271 if opts.IO.CanPrompt() {
272 bodyInput, err := opts.Prompter.Input("Paste your variable", "")
273 if err != nil {
274 return "", err
275 }
276 fmt.Fprintln(opts.IO.Out)
277 return bodyInput, nil
278 }
279
280 body, err := io.ReadAll(opts.IO.In)
281 if err != nil {
282 return "", fmt.Errorf("failed to read from standard input: %w", err)
283 }
284
285 return string(bytes.TrimRight(body, "\r\n")), nil
286}
287
288func getRepoIds(client *api.Client, host, owner string, repositoryNames []string) ([]int64, error) {
289 if len(repositoryNames) == 0 {

Callers 3

getVariablesFromOptionsFunction · 0.70
Test_getBody_promptFunction · 0.70
Test_getBodyFunction · 0.70

Calls 3

CanPromptMethod · 0.80
InputMethod · 0.65
ErrorfMethod · 0.65

Tested by 2

Test_getBody_promptFunction · 0.56
Test_getBodyFunction · 0.56