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

output

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package output provides formatting for diff output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatFileList

func FormatFileList(w io.Writer, parsed *diff.ParsedDiff) error

FormatFileList writes just the list of changed files.

func FormatJSON

func FormatJSON(w io.Writer, parsed *diff.ParsedDiff) error

FormatJSON writes the parsed diff as JSON.

func FormatJSONEmpty

func FormatJSONEmpty(w io.Writer) error

FormatJSONEmpty writes an empty JSON response.

func FormatJSONEmptyWithUntracked

func FormatJSONEmptyWithUntracked(w io.Writer, untracked []string) error

FormatJSONEmptyWithUntracked writes an empty JSON response with untracked files.

func FormatJSONWithUntracked

func FormatJSONWithUntracked(w io.Writer, parsed *diff.ParsedDiff, untracked []string) error

FormatJSONWithUntracked writes the parsed diff as JSON, including untracked files.

func FormatRaw

func FormatRaw(w io.Writer, parsed *diff.ParsedDiff) error

FormatRaw writes the diff in its original unified format.

func FormatStageableLines

func FormatStageableLines(w io.Writer, parsed *diff.ParsedDiff) error

FormatStageableLines writes lines that can be staged with line numbers. This is the format most useful for agents.

func FormatStagingCommands

func FormatStagingCommands(w io.Writer, parsed *diff.ParsedDiff) error

FormatStagingCommands writes suggested stage commands.

func FormatText

func FormatText(
	w io.Writer, parsed *diff.ParsedDiff, opts TextOptions,
) error

FormatText writes the parsed diff as formatted text.

func FormatTextSummary

func FormatTextSummary(w io.Writer, parsed *diff.ParsedDiff) error

FormatTextSummary writes a brief summary of changes.

Types

type DiffOutput

type DiffOutput struct {
	Files     []FileOutput `json:"files"`
	Untracked []string     `json:"untracked,omitempty"`
}

DiffOutput is the top-level JSON output structure.

type FileOutput

type FileOutput struct {
	Path    string       `json:"path"`
	OldPath string       `json:"old_path,omitempty"`
	Status  string       `json:"status"` // "modified", "new", "deleted", "renamed"
	Binary  bool         `json:"binary,omitempty"`
	Hunks   []HunkOutput `json:"hunks,omitempty"`
}

FileOutput represents a file in JSON output.

type HunkOutput

type HunkOutput struct {
	Header  string       `json:"header"`
	Section string       `json:"section,omitempty"`
	Hunks   []LineOutput `json:"lines"`
}

HunkOutput represents a hunk in JSON output.

type LineOutput

type LineOutput struct {
	Op         string `json:"op"` // "add", "delete", "context"
	Content    string `json:"content"`
	OldLineNum int    `json:"old_line,omitempty"`
	NewLineNum int    `json:"new_line,omitempty"`
}

LineOutput represents a line in JSON output.

type TextOptions

type TextOptions struct {
	// Color enables ANSI color codes.
	Color bool

	// LineNumbers shows line numbers.
	LineNumbers bool

	// Stats shows +/- statistics.
	Stats bool
}

TextOptions configures text output formatting.

func DefaultTextOptions

func DefaultTextOptions() TextOptions

DefaultTextOptions returns default text formatting options.

Jump to

Keyboard shortcuts

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