cliio

package
v0.0.16 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadWithLimit

func ReadWithLimit(r io.Reader, maxBytes int64) ([]byte, error)

ReadWithLimit reads from reader with maximum size enforcement.

func ResolveInput

func ResolveInput(cmd *cobra.Command, inputFile string) ([]byte, error)

ResolveInput reads input from file or stdin with size limits and security checks.

func WriteOutput

func WriteOutput(cmd *cobra.Command, outputFile string, data []byte) error

WriteOutput writes data to file or stdout.

Types

type CLIPrinter

type CLIPrinter struct {
	// contains filtered or unexported fields
}

CLIPrinter implements Printer with support for multiple output formats.

func NewCLIPrinter

func NewCLIPrinter(out, errOut io.Writer, format Format) *CLIPrinter

NewCLIPrinter creates a printer with specified output writers and format.

func (*CLIPrinter) Print

func (p *CLIPrinter) Print(v any)

Print outputs data in the configured format (JSON, YAML, or table).

func (*CLIPrinter) PrintError

func (p *CLIPrinter) PrintError(err error)

PrintError outputs errors in human-readable or JSON format.

type Codec

type Codec interface {
	Encode(txID string, tx *applicationpb.Tx) ([]byte, error)
	Decode(data []byte) (txID string, tx *applicationpb.Tx, err error)
}

Codec handles encoding and decoding of transactions for CLI I/O.

type Format

type Format string

Format specifies the output format for CLI printing.

const (
	FormatTable Format = "table"
	FormatJSON  Format = "json"
	FormatYAML  Format = "yaml"
)

Define available format types.

type IOFlags

type IOFlags struct {
	Input  string
	Output string
}

IOFlags groups input and output file path flags.

func (*IOFlags) Bind

func (f *IOFlags) Bind(cmd *cobra.Command)

Bind registers input and output flags on the command.

type JSONCodec

type JSONCodec struct{}

JSONCodec implements Codec using JSON format with protobuf marshaling.

func (*JSONCodec) Decode

func (*JSONCodec) Decode(data []byte) (string, *applicationpb.Tx, error)

Decode parses JSON data into transaction ID and transaction.

func (*JSONCodec) Encode

func (*JSONCodec) Encode(txID string, tx *applicationpb.Tx) ([]byte, error)

Encode converts a transaction to JSON format with transaction ID.

type Printer

type Printer interface {
	Print(v any)
	PrintError(err error)
}

Printer handles formatted output for CLI commands.

Jump to

Keyboard shortcuts

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