Help us shape the future of Go! Take the 2026 Go Developer Survey

cliutil

package
v0.26.0 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package cliutil provides shared filter-parsing and output helpers used by both cmd/bintrail/ commands and cmd/bintrail-mcp/.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildIndexFilters

func BuildIndexFilters(schemas, tables string) event.Filters

BuildIndexFilters builds an event.Filters from comma-separated schema and table flag values.

func IsValidFormat

func IsValidFormat(s string) bool

IsValidFormat reports whether s is a supported query output format (table, json, or csv).

func IsValidOutputFormat

func IsValidOutputFormat(s string) bool

IsValidOutputFormat reports whether s is a supported general output format (text or json). Used by commands other than query (init, snapshot, index, status, recover, etc.).

func OutputJSON

func OutputJSON(v any) error

OutputJSON encodes v as indented JSON to stdout.

func ParseByteSize added in v0.17.0

func ParseByteSize(s string) (int64, error)

ParseByteSize parses a human-readable byte size string like "256MB" or "1GB". Plain integers are treated as bytes. Returns 0 for "0" (unlimited). Shared by the agent (--buffer-max-bytes) and reconstruct (--chunk-size) commands.

func ParseEventType

func ParseEventType(s string) (*event.EventType, error)

ParseEventType converts an event-type string to a *event.EventType. Returns nil for an empty string (meaning "all types").

func ParseRetain

func ParseRetain(s string) (time.Duration, error)

ParseRetain parses a retain string like "7d" or "24h" into a time.Duration. Supported units: 'd' (days), 'h' (hours). The number must be a positive integer.

func ParseSchemaList

func ParseSchemaList(s string) []string

ParseSchemaList splits a comma-separated schema string into a trimmed slice, dropping empty entries. Returns nil if the input is empty.

func ParseTime

func ParseTime(s string) (*time.Time, error)

ParseTime parses a datetime string as UTC. Accepts three formats (tried in order):

  • MySQL datetime: "2006-01-02 15:04:05" (interpreted as UTC)
  • RFC 3339: "2006-01-02T15:04:05Z07:00" (timezone from string)
  • Date-only: "2006-01-02" (interpreted as midnight UTC)

Returns nil for an empty string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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