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

Function getBody

pkg/cmd/secret/set/set.go:413–433  ·  view source on GitHub ↗
(opts *SetOptions)

Source from the content-addressed store, hash-verified

411}
412
413func getBody(opts *SetOptions) ([]byte, error) {
414 if opts.Body != "" {
415 return []byte(opts.Body), nil
416 }
417
418 if opts.IO.CanPrompt() {
419 bodyInput, err := opts.Prompter.Password("Paste your secret:")
420 if err != nil {
421 return nil, err
422 }
423 fmt.Fprintln(opts.IO.Out)
424 return []byte(bodyInput), nil
425 }
426
427 body, err := io.ReadAll(opts.IO.In)
428 if err != nil {
429 return nil, fmt.Errorf("failed to read from standard input: %w", err)
430 }
431
432 return bytes.TrimRight(body, "\r\n"), nil
433}
434
435func mapRepoNamesToIDs(client *api.Client, host, defaultOwner string, repositoryNames []string) ([]int64, error) {
436 repos := make([]ghrepo.Interface, 0, len(repositoryNames))

Callers 3

getSecretsFromOptionsFunction · 0.70
Test_getBodyFunction · 0.70
Test_getBodyPromptFunction · 0.70

Calls 3

CanPromptMethod · 0.80
PasswordMethod · 0.65
ErrorfMethod · 0.65

Tested by 2

Test_getBodyFunction · 0.56
Test_getBodyPromptFunction · 0.56