ReadInputWithFallback tries to read from the specified source with stdin fallback.
(args []string)
| 294 | |
| 295 | // ReadInputWithFallback tries to read from the specified source with stdin fallback. |
| 296 | func ReadInputWithFallback(args []string) (*InputResult, error) { |
| 297 | useStdin, inputArg, err := DetectInputMode(args) |
| 298 | if err != nil { |
| 299 | return nil, err |
| 300 | } |
| 301 | |
| 302 | if useStdin { |
| 303 | content, err := ReadFromStdin() |
| 304 | if err != nil { |
| 305 | return nil, err |
| 306 | } |
| 307 | |
| 308 | if err := ValidateStdinInput(content); err != nil { |
| 309 | return nil, fmt.Errorf("stdin validation failed: %w", err) |
| 310 | } |
| 311 | |
| 312 | return &InputResult{ |
| 313 | Type: InputTypeSQL, |
| 314 | Content: content, |
| 315 | Source: "stdin", |
| 316 | }, nil |
| 317 | } |
| 318 | |
| 319 | return GetInputSource(inputArg) |
| 320 | } |
| 321 | |
| 322 | // ShouldReadFromStdin determines if we should read from stdin based on args. |
| 323 | func ShouldReadFromStdin(args []string) bool { |
nothing calls this directly
no test coverage detected