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

collector

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package collector implements the CommandCollectorPlugin: a read-only transform plugin that walks the parsed AST and reports the command name of every leaf SimpleCommand it encounters.

The plugin does NOT mutate the AST. Its metadata payload is a `[]string` of command names, in source order, stored under the plugin's Name() ("command-collector") in the pipeline metadata bag and surfaced from Bash.Exec via BashExecResult.Metadata.

Index

Constants

View Source
const MetadataKey = "commands"

MetadataKey is the JSON-style key for the collected list within the plugin's metadata payload. The full plugin payload is exposed under

transform.BashTransformResult.Metadata[Name] = map[string]any{
    MetadataKey: []string{...},
}.
View Source
const Name = "command-collector"

Name is the metadata key the plugin uses.

Variables

This section is empty.

Functions

This section is empty.

Types

type Plugin

type Plugin struct{}

Plugin is the CommandCollectorPlugin instance. Stateless; safe to share across pipelines.

func New

func New() *Plugin

New returns a fresh CommandCollectorPlugin.

func (*Plugin) Name

func (*Plugin) Name() string

Name implements transform.Plugin.

func (*Plugin) Transform

func (*Plugin) Transform(ctx transform.Context) transform.Result

Transform walks the script's Origin syntax tree and collects the first-argument literal of every CallExpr (which corresponds to a SimpleCommand in our typed AST). Compound commands (if / while / subshell / etc.) are recursed into transparently by mvdan/sh's syntax.Walk; their bodies' SimpleCommands are collected too.

Jump to

Keyboard shortcuts

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