report

package
v0.0.0-...-374cbe0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatMarkdown

func FormatMarkdown(results []Result) string

FormatMarkdown formats the results as a Markdown report.

func FormatReport

func FormatReport(results []Result, format Format) (string, error)

FormatReport dispatches to the appropriate formatter based on the format.

func FormatXML

func FormatXML(results []Result) (string, error)

FormatXML formats the results as an XML report using encoding/xml for proper escaping.

func ResolveInput

func ResolveInput(stdin io.Reader, filePath string, args []string, isInputTTY bool) (string, error)

ResolveInput determines the input text from the available sources. Priority: filePath > piped stdin > args > error.

Types

type Action

type Action struct {
	Description string
	Command     string
}

Action represents a parsed command with its description.

func ParseActions

func ParseActions(text string) []Action

ParseActions parses a text block into a slice of Actions.

Rules:

  1. Lines starting with # → strip "# " prefix, trim whitespace, set as description for the next action
  2. Lines ending with \ → join with next line (strip trailing \, strip leading whitespace from next, join with space)
  3. Blank lines → skip
  4. Any other line (or completed continuation) → becomes Command of a new Action
  5. No preceding # comment → Description is empty string
  6. Multiple consecutive # lines → last one wins
  7. Trailing # comment with no following command → ignored

type Format

type Format string

Format represents the output format for the report.

const (
	XML      Format = "xml"
	Markdown Format = "md"
)

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat validates and returns a Format from a string.

type OnErrorBehavior

type OnErrorBehavior string

OnErrorBehavior controls what happens when a command fails.

const (
	Continue OnErrorBehavior = "continue"
	Stop     OnErrorBehavior = "stop"
)

func ParseOnErrorBehavior

func ParseOnErrorBehavior(s string) (OnErrorBehavior, error)

ParseOnErrorBehavior validates and returns an OnErrorBehavior from a string.

type Result

type Result struct {
	Action   Action
	ExitCode int
	Output   string
}

Result represents the outcome of executing an Action.

func ExecuteActions

func ExecuteActions(actions []Action, onError OnErrorBehavior, shell string) []Result

ExecuteActions runs each action using the given shell and collects results. If onError is Stop and a command fails, execution halts and partial results are returned.

Jump to

Keyboard shortcuts

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