Documentation
¶
Index ¶
- Variables
- func Format(w io.Writer, rows []Row, columns []string, format string) error
- func InferColumns(rows []Row) []string
- func InferFormatFromPath(path string) string
- func IsTerminal() bool
- func OpenWriter(path string) (io.Writer, func() error, error)
- func ResolveFormat(format string) string
- type Row
Constants ¶
This section is empty.
Variables ¶
var DefaultColumns = []string{
"sample_accession",
"organism",
"tissue",
"age",
"sex",
"disease",
}
DefaultColumns lists sensible defaults for BioSample queries.
Functions ¶
func Format ¶
Format writes rows to w in the requested format. Supported formats: tsv, csv, json, table.
func InferColumns ¶
InferColumns collects all keys from rows, sorts them alphabetically, and puts sample_accession first if present.
func InferFormatFromPath ¶ added in v0.15.0
InferFormatFromPath returns "tsv", "csv", "json", or "" based on the file extension (after stripping a trailing .gz). Returns "" when the extension is missing or unrecognised so callers can fall through to their own defaults.
Exposed as a separate step (rather than baked into ResolveFormat) so each command can interleave it with config-driven defaults in the correct priority: --format flag > filename hint > configured default > TTY default.
func IsTerminal ¶
func IsTerminal() bool
func OpenWriter ¶ added in v0.15.0
OpenWriter creates the file at path and returns a writer plus a close function. When path ends with .gz (case-insensitive) the returned writer is a gzip.Writer wrapping the file; the close function flushes the gzip stream and closes the underlying file. Callers must invoke close to avoid silently truncating the gzip trailer.