Documentation
¶
Overview ¶
Package output provides formatting for diff output.
Index ¶
- func FormatFileList(w io.Writer, parsed *diff.ParsedDiff) error
- func FormatJSON(w io.Writer, parsed *diff.ParsedDiff) error
- func FormatJSONEmpty(w io.Writer) error
- func FormatJSONEmptyWithUntracked(w io.Writer, untracked []string) error
- func FormatJSONWithUntracked(w io.Writer, parsed *diff.ParsedDiff, untracked []string) error
- func FormatRaw(w io.Writer, parsed *diff.ParsedDiff) error
- func FormatStageableLines(w io.Writer, parsed *diff.ParsedDiff) error
- func FormatStagingCommands(w io.Writer, parsed *diff.ParsedDiff) error
- func FormatText(w io.Writer, parsed *diff.ParsedDiff, opts TextOptions) error
- func FormatTextSummary(w io.Writer, parsed *diff.ParsedDiff) error
- type DiffOutput
- type FileOutput
- type HunkOutput
- type LineOutput
- type TextOptions
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 ¶
FormatJSONEmpty writes an empty JSON response.
func FormatJSONEmptyWithUntracked ¶
FormatJSONEmptyWithUntracked writes an empty JSON response with untracked files.
func FormatJSONWithUntracked ¶
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.