Skip to content

Allow user TOML filters to customize built-in command output #821

@thegiantbeast

Description

@thegiantbeast

Problem

Built-in Rust commands (git, kubectl, npm, docker, etc.) are routed by Clap before the TOML engine runs. User TOML filters can only target commands that RTK doesn't already handle natively.

This means there's no way to customize how built-in commands filter output. For example, kubectl top and kubectl exec go through the built-in kubectl handler, but their output characteristics are very different from kubectl get. A user can't write a TOML filter to handle kubectl top differently because kubectl as a whole is claimed by the Rust binary.

Use case

# This doesn't work — kubectl is a built-in command
[filters.kubectl-top]
description = "Compact kubectl top output"
match_command = "^kubectl\\s+top\\b"
strip_ansi = true
strip_lines_matching = ["^\\s*$"]

The TOML engine never sees kubectl top because Clap routes all kubectl * to the built-in handler first.

Proposed approach

Allow user TOML filters to match specific subcommands of built-in commands. For example, if a user defines a filter matching ^kubectl\s+top\b, it should take precedence over the generic built-in kubectl handler for that specific subcommand pattern.

The priority could be: user TOML (specific subcommand match) > built-in Rust handler > user TOML (generic).

Happy to send a PR if this approach makes sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions