MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / ReadInputWithFallback

Function ReadInputWithFallback

cmd/gosqlx/internal/cmdutil/input.go:296–320  ·  view source on GitHub ↗

ReadInputWithFallback tries to read from the specified source with stdin fallback.

(args []string)

Source from the content-addressed store, hash-verified

294
295// ReadInputWithFallback tries to read from the specified source with stdin fallback.
296func 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.
323func ShouldReadFromStdin(args []string) bool {

Callers

nothing calls this directly

Calls 5

DetectInputModeFunction · 0.70
ReadFromStdinFunction · 0.70
ValidateStdinInputFunction · 0.70
GetInputSourceFunction · 0.70
ErrorfMethod · 0.65

Tested by

no test coverage detected