sqlinput

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package sqlinput resolves SQL text from the three input sources every SQL-consuming subcommand supports: an inline -e expression, a positional file argument, or standard input. The resolution logic lives here so validate, format, parse, and future subcommands share one implementation and one set of error messages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadSQL

func ReadSQL(expr string, args []string, stdin io.Reader) (string, error)

ReadSQL resolves SQL input from three sources in priority order:

  1. expr — the -e / --expression flag value (inline SQL).
  2. args — a single positional argument treated as a file path.
  3. stdin — standard input, read until EOF.

If expr is non-empty, args must be empty (returning an error otherwise). If both expr and args are empty, stdin is consumed. An error is returned when the resolved input is empty after trimming whitespace.

stdin is an io.Reader rather than *os.File so callers can inject a bytes.Buffer or strings.Reader in tests. The cobra command passes cmd.InOrStdin().

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL