(ctx context.Context, content, filePath string)
| 19 | const docsAtIndexEnd = "end" |
| 20 | |
| 21 | func resolveContentInput(ctx context.Context, content, filePath string) (string, error) { |
| 22 | if content != "" { |
| 23 | return content, nil |
| 24 | } |
| 25 | if filePath != "" { |
| 26 | if filePath == "-" { |
| 27 | data, err := io.ReadAll(stdinReader(ctx)) |
| 28 | if err != nil { |
| 29 | return "", fmt.Errorf("reading stdin: %w", err) |
| 30 | } |
| 31 | return string(data), nil |
| 32 | } |
| 33 | data, err := os.ReadFile(filePath) //nolint:gosec // user-provided path |
| 34 | if err != nil { |
| 35 | return "", fmt.Errorf("reading file: %w", err) |
| 36 | } |
| 37 | return string(data), nil |
| 38 | } |
| 39 | if !stdinIsTerminal(ctx) { |
| 40 | data, err := io.ReadAll(stdinReader(ctx)) |
| 41 | if err != nil { |
| 42 | return "", fmt.Errorf("reading stdin: %w", err) |
| 43 | } |
| 44 | return string(data), nil |
| 45 | } |
| 46 | return "", nil |
| 47 | } |
| 48 | |
| 49 | func docsWebViewLink(id string) string { |
| 50 | id = strings.TrimSpace(id) |
no test coverage detected