rtkcompat

package module
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package rtkcompat loads rtk's TOML filter definitions and converts them to native gortk Specs. It lets gortk ingest rtk's built-in filters — and any community filters in the same format — verbatim, instead of re-porting them.

This is the ONLY part of gortk that depends on a TOML parser; the core package stays dependency-free. Import this package only if you want rtk-TOML ingestion.

Field mapping (rtk -> gortk.Spec):

match_command         -> Match.CommandRegex
strip_ansi            -> Lines.StripANSI
strip_lines_matching  -> Lines.DropRegexps
keep_lines_matching   -> Lines.KeepRegexps
truncate_lines_at     -> Lines.TruncateLinesAt
max_lines             -> Limit.MaxLines (Keep "tail")
head_lines/tail_lines -> Limit.Keep "head"/"tail"
on_empty              -> EmptyText
match_output          -> MatchOutput
filter_stderr         -> Lines.Source ("both" when true, else "stdout")
description, replace  -> dropped (replace is unsupported by gortk)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadTOML

func LoadTOML(data []byte) ([]gortk.Spec, error)

LoadTOML parses an rtk filter file and returns the equivalent gortk Specs, sorted by filter name for deterministic ordering. The Specs are returned uncompiled — call Spec.Validate (or register them) to surface regex errors.

func Register

func Register(reg *gortk.Registry, data []byte) error

Register converts an rtk filter file and adds every filter to reg. It returns the first conversion/compile error encountered (and registers nothing on a parse error).

Types

type Fixture

type Fixture struct {
	Filter   string `json:"filter"`
	Name     string `json:"name"`
	Input    string `json:"input"`
	Expected string `json:"expected"`
}

Fixture is one rtk test case, flattened with the filter it belongs to. rtk compares filter output to Expected with trailing newlines trimmed.

func LoadTests

func LoadTests(data []byte) ([]Fixture, error)

LoadTests extracts the [[tests.<filter>]] cases from an rtk filter file.

Directories

Path Synopsis
cmd
rtk2json command
Command rtk2json converts rtk TOML filter files into gortk JSON Specs.
Command rtk2json converts rtk TOML filter files into gortk JSON Specs.
rtksync command
Command rtksync imports rtk's entire TOML filter catalog into specs/rtk.json.
Command rtksync imports rtk's entire TOML filter catalog into specs/rtk.json.

Jump to

Keyboard shortcuts

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