output

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package output provides formatters for exporting command results in various formats. It supports CSV, JSON, and XML output formats as alternatives to the default table display.

Package output provides utilities for formatting command output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsStructuredFormat

func IsStructuredFormat(f Format) bool

IsStructuredFormat returns true if the format requires structured output (not table).

Structured formats (CSV, JSON, XML) are typically used for machine consumption and require different data collection than the interactive table format.

Parameters:

  • f: The format to check

Returns:

  • bool: true if format is CSV, JSON, or XML; false for table format

func ShouldShowGroupColumn

func ShouldShowGroupColumn(groups []string) bool

ShouldShowGroupColumn determines if a GROUP column should be displayed.

It performs the following operations:

  • Step 1: Counts occurrences of each unique group (ignoring empty/whitespace-only groups)
  • Step 2: Checks if any group appears 2 or more times

This is a common pattern used across list, outdated, and update commands to avoid showing an empty or single-item group column.

Parameters:

  • groups: Slice of group names, may contain duplicates, empty strings, or whitespace

Returns:

  • bool: true if at least one group has 2 or more items; false otherwise

func ValidateStructuredOutputFlags

func ValidateStructuredOutputFlags(format Format, verbose bool) error

ValidateStructuredOutputFlags validates that flags are compatible with structured output formats.

When using structured output (JSON, CSV, XML), certain interactive and verbose flags are not supported because:

  • Progress messages are suppressed (not sent to stderr)
  • Verbose output would corrupt the structured data
  • Interactive prompts are not compatible with machine-readable output

Parameters:

  • format: The output format being used
  • verbose: Whether --verbose flag is enabled

Returns:

  • error: Validation error describing the incompatible flags, or nil if valid

func ValidateUpdateStructuredFlags

func ValidateUpdateStructuredFlags(format Format, yes, dryRun bool) error

ValidateUpdateStructuredFlags validates update command flags for structured output.

When using structured output with the update command, either --yes or --dry-run must be specified because interactive confirmation prompts are not compatible with machine-readable output.

Parameters:

  • format: The output format being used
  • yes: Whether --yes flag is enabled (skip confirmation)
  • dryRun: Whether --dry-run flag is enabled (preview only)

Returns:

  • error: Validation error if neither flag is set with structured output, or nil if valid

func WriteListResult

func WriteListResult(w io.Writer, format Format, result *ListResult) error

WriteListResult writes list results in the specified format.

It performs the following operations:

  • Step 1: Creates a formatter for the requested format
  • Step 2: Writes the list result using format-specific logic

Parameters:

  • w: Destination writer for the output
  • format: Output format (FormatJSON, FormatXML, or FormatCSV)
  • result: List result data to write

Returns:

  • error: When format is unsupported, returns an error; when write fails, returns the underlying error; otherwise returns nil

func WriteOutdatedResult

func WriteOutdatedResult(w io.Writer, format Format, result *OutdatedResult) error

WriteOutdatedResult writes outdated results in the specified format.

It performs the following operations:

  • Step 1: Creates a formatter for the requested format
  • Step 2: Writes the outdated result using format-specific logic

Parameters:

  • w: Destination writer for the output
  • format: Output format (FormatJSON, FormatXML, or FormatCSV)
  • result: Outdated result data to write

Returns:

  • error: When format is unsupported, returns an error; when write fails, returns the underlying error; otherwise returns nil

func WriteScanResult

func WriteScanResult(w io.Writer, format Format, result *ScanResult) error

WriteScanResult writes scan results in the specified format.

It performs the following operations:

  • Step 1: Creates a formatter for the requested format
  • Step 2: Writes the scan result using format-specific logic

Parameters:

  • w: Destination writer for the output
  • format: Output format (FormatJSON, FormatXML, or FormatCSV)
  • result: Scan result data to write

Returns:

  • error: When format is unsupported, returns an error; when write fails, returns the underlying error; otherwise returns nil

func WriteUpdateResult

func WriteUpdateResult(w io.Writer, format Format, result *UpdateResult) error

WriteUpdateResult writes update results in the specified format.

It performs the following operations:

  • Step 1: Creates a formatter for the requested format
  • Step 2: Writes the update result using format-specific logic

Parameters:

  • w: Destination writer for the output
  • format: Output format (FormatJSON, FormatXML, or FormatCSV)
  • result: Update result data to write

Returns:

  • error: When format is unsupported, returns an error; when write fails, returns the underlying error; otherwise returns nil

Types

type Column

type Column struct {
	Header string
	Width  int
	// contains filtered or unexported fields
}

Column represents a single table column with its header and current width.

Fields:

  • Header: The display text for this column's header
  • Width: The current display width for this column in characters
  • hidden: Whether this column should be excluded from output

type Format

type Format string

Format represents the output format type.

const (
	// FormatTable is the default terminal table output.
	FormatTable Format = "table"
	// FormatCSV outputs data as comma-separated values.
	FormatCSV Format = "csv"
	// FormatJSON outputs data as JSON.
	FormatJSON Format = "json"
	// FormatXML outputs data as XML.
	FormatXML Format = "xml"
)

func ParseFormat

func ParseFormat(s string) Format

ParseFormat parses a format string into a Format type.

The parsing is case-insensitive. Valid values are "csv", "json", and "xml". Any unrecognized format returns FormatTable as the default.

Parameters:

  • s: Format string to parse (e.g., "csv", "JSON", "XmL")

Returns:

  • Format: The parsed format, or FormatTable if unrecognized

type Formatter

type Formatter struct {
	// contains filtered or unexported fields
}

Formatter handles writing data in a specific format.

Fields:

  • format: The output format (CSV, JSON, XML, or Table)
  • writer: Destination for formatted output

func NewFormatter

func NewFormatter(format Format, writer io.Writer) *Formatter

NewFormatter creates a new formatter for the given format and writer.

Parameters:

  • format: The desired output format
  • writer: Destination for formatted output

Returns:

  • *Formatter: A new formatter instance ready to write data

func (*Formatter) Format

func (f *Formatter) Format() Format

Format returns the current format.

Returns:

  • Format: The format this formatter is configured to use

func (*Formatter) WriteCSV

func (f *Formatter) WriteCSV(headers []string, rows [][]string) error

WriteCSV writes data as CSV to the output writer.

It performs the following operations:

  • Step 1: Creates a CSV writer
  • Step 2: Writes the header row
  • Step 3: Writes all data rows
  • Step 4: Flushes the buffer and returns any errors

Note: csv.Writer buffers all writes and only reports errors via Error() after Flush().

Parameters:

  • headers: Column headers for the CSV
  • rows: Data rows, each row should have the same number of columns as headers

Returns:

  • error: When write or flush fails, returns the underlying error; otherwise returns nil

func (*Formatter) WriteJSON

func (f *Formatter) WriteJSON(data interface{}) error

WriteJSON writes data as compact JSON to the output writer.

The output is compact (single line) for easy parsing by tools.

Parameters:

  • data: Data structure to encode as JSON (must be marshallable)

Returns:

  • error: When encoding fails, returns the underlying error; otherwise returns nil

func (*Formatter) WriteXML

func (f *Formatter) WriteXML(data interface{}) error

WriteXML writes data as XML to the output writer.

It performs the following operations:

  • Step 1: Writes the XML header (<?xml version="1.0"?>)
  • Step 2: Encodes the data with 2-space indentation
  • Step 3: Adds a trailing newline

Parameters:

  • data: Data structure to encode as XML (must be marshallable and have xml tags)

Returns:

  • error: When encoding fails, returns the underlying error; otherwise returns nil

type ListPackage

type ListPackage struct {
	Rule             string `json:"rule" xml:"rule"`
	PM               string `json:"pm" xml:"pm"`
	Type             string `json:"type" xml:"type"`
	Constraint       string `json:"constraint" xml:"constraint"`
	Version          string `json:"version" xml:"version"`
	InstalledVersion string `json:"installed_version" xml:"installedVersion"`
	Status           string `json:"status" xml:"status"`
	Group            string `json:"group,omitempty" xml:"group,omitempty"`
	Name             string `json:"name" xml:"name"`
	IgnoreReason     string `json:"ignore_reason,omitempty" xml:"ignoreReason,omitempty"`
}

ListPackage represents a package entry in the list output.

Fields:

  • Rule: The pattern matching rule that identified this package
  • PM: Package manager identifier (e.g., "npm", "pip", "go")
  • Type: Package type (e.g., "direct", "dev", "peer")
  • Constraint: Version constraint specified in the dependency file
  • Version: Latest available version
  • InstalledVersion: Currently installed version
  • Status: Current status of the package (e.g., "ok", "missing")
  • Group: Optional grouping identifier (omitted if empty)
  • Name: Package name

type ListResult

type ListResult struct {
	XMLName  xml.Name      `json:"-" xml:"listResult"`
	Summary  ListSummary   `json:"summary" xml:"summary"`
	Packages []ListPackage `json:"packages" xml:"packages>package"`
	Warnings []string      `json:"warnings,omitempty" xml:"warnings>warning,omitempty"`
}

ListResult represents the output data for the list command.

Fields:

  • XMLName: XML root element name (used only for XML marshaling)
  • Summary: Aggregate statistics about the list operation
  • Packages: List of package entries
  • Warnings: Warning messages generated during the list operation (omitted if empty)

type ListSummary

type ListSummary struct {
	TotalPackages int `json:"total_packages" xml:"totalPackages"`
}

ListSummary holds summary statistics for list results.

Fields:

  • TotalPackages: Total number of packages in the list

type OutdatedPackage

type OutdatedPackage struct {
	Rule             string `json:"rule" xml:"rule"`
	PM               string `json:"pm" xml:"pm"`
	Type             string `json:"type" xml:"type"`
	Constraint       string `json:"constraint" xml:"constraint"`
	Version          string `json:"version" xml:"version"`
	InstalledVersion string `json:"installed_version" xml:"installedVersion"`
	Major            string `json:"major" xml:"major"`
	Minor            string `json:"minor" xml:"minor"`
	Patch            string `json:"patch" xml:"patch"`
	Status           string `json:"status" xml:"status"`
	Group            string `json:"group,omitempty" xml:"group,omitempty"`
	Name             string `json:"name" xml:"name"`
	Error            string `json:"error,omitempty" xml:"error,omitempty"`
}

OutdatedPackage represents a package entry in the outdated output.

Fields:

  • Rule: The pattern matching rule that identified this package
  • PM: Package manager identifier (e.g., "npm", "pip", "go")
  • Type: Package type (e.g., "direct", "dev", "peer")
  • Constraint: Version constraint specified in the dependency file
  • Version: Latest available version
  • InstalledVersion: Currently installed version
  • Major: Latest available major version
  • Minor: Latest available minor version
  • Patch: Latest available patch version
  • Status: Current status (e.g., "outdated", "up-to-date", "failed")
  • Group: Optional grouping identifier (omitted if empty)
  • Name: Package name
  • Error: Error message if the version check failed (omitted if empty)

type OutdatedResult

type OutdatedResult struct {
	XMLName  xml.Name          `json:"-" xml:"outdatedResult"`
	Summary  OutdatedSummary   `json:"summary" xml:"summary"`
	Packages []OutdatedPackage `json:"packages" xml:"packages>package"`
	Warnings []string          `json:"warnings,omitempty" xml:"warnings>warning,omitempty"`
	Errors   []string          `json:"errors,omitempty" xml:"errors>error,omitempty"`
}

OutdatedResult represents the output data for the outdated command.

Fields:

  • XMLName: XML root element name (used only for XML marshaling)
  • Summary: Aggregate statistics about the outdated operation
  • Packages: List of package entries with version information
  • Warnings: Warning messages generated during the outdated check (omitted if empty)
  • Errors: Error messages generated during the outdated check (omitted if empty)

type OutdatedSummary

type OutdatedSummary struct {
	TotalPackages    int `json:"total_packages" xml:"totalPackages"`
	OutdatedPackages int `json:"outdated_packages" xml:"outdatedPackages"`
	UpToDatePackages int `json:"uptodate_packages" xml:"uptodatePackages"`
	FailedPackages   int `json:"failed_packages" xml:"failedPackages"`
	HasMajor         int `json:"has_major" xml:"hasMajor"`
	HasMinor         int `json:"has_minor" xml:"hasMinor"`
	HasPatch         int `json:"has_patch" xml:"hasPatch"`
}

OutdatedSummary holds summary statistics for outdated results.

Fields:

  • TotalPackages: Total number of packages checked
  • OutdatedPackages: Number of packages with available updates
  • UpToDatePackages: Number of packages already at the latest version
  • FailedPackages: Number of packages that failed the version check
  • HasMajor: Number of packages with major updates available
  • HasMinor: Number of packages with minor updates available
  • HasPatch: Number of packages with patch updates available

type Progress

type Progress struct {
	// contains filtered or unexported fields
}

Progress provides a simple progress indicator for long-running operations.

Fields:

  • writer: Destination for progress output (typically os.Stderr)
  • total: Total number of steps in the operation
  • current: Current step number
  • message: Descriptive message displayed with the progress
  • mu: Mutex to protect concurrent access to progress state
  • enabled: Whether progress output is enabled
  • lastWidth: Width of the last rendered progress line for proper clearing

func NewProgress

func NewProgress(writer io.Writer, total int, message string) *Progress

NewProgress creates a new progress indicator and returns it.

Parameters:

  • writer: Destination for progress output (typically os.Stderr)
  • total: Total number of steps in the operation
  • message: Descriptive message to display (e.g., "Processing packages")

Returns:

  • *Progress: A new progress indicator initialized and enabled

func (*Progress) Clear

func (p *Progress) Clear()

Clear clears the progress line from the display.

This overwrites the current progress line with spaces and returns the cursor to the beginning. Useful when you need to print other content without the progress indicator interfering. If the receiver is nil, this method is a no-op (nil-safe).

func (*Progress) Done

func (p *Progress) Done()

Done marks the progress as complete and prints a newline.

It performs the following operations:

  • Step 1: Sets current to total to show 100% completion
  • Step 2: Renders the final progress state
  • Step 3: Prints a newline to move past the progress line

This should be called when the operation completes successfully. If the receiver is nil, this method is a no-op (nil-safe).

func (*Progress) Increment

func (p *Progress) Increment()

Increment advances the progress by one step and re-renders the display.

It performs the following operations:

  • Step 1: Locks mutex, increments counter, copies values, unlocks
  • Step 2: Renders progress outside the critical section to prevent I/O deadlocks

This method is thread-safe and can be called concurrently from multiple goroutines. If the receiver is nil, this method is a no-op (nil-safe).

func (*Progress) SetCurrent

func (p *Progress) SetCurrent(current int)

SetCurrent sets the current progress value to a specific step and re-renders.

It performs the following operations:

  • Step 1: Locks mutex, updates current value, copies values, unlocks
  • Step 2: Renders progress outside the critical section to prevent I/O deadlocks

Parameters:

  • current: The step number to set (0 to total)

This method is thread-safe. If the receiver is nil, this method is a no-op (nil-safe).

func (*Progress) SetEnabled

func (p *Progress) SetEnabled(enabled bool)

SetEnabled enables or disables progress output.

This is useful for suppressing progress in non-interactive environments or when structured output formats are used.

Parameters:

  • enabled: true to enable progress output; false to disable

If the receiver is nil, this method is a no-op (nil-safe).

type ScanEntry

type ScanEntry struct {
	Rule   string `json:"rule" xml:"rule"`
	PM     string `json:"pm" xml:"pm"`
	Format string `json:"format" xml:"format"`
	File   string `json:"file" xml:"file"`
	Status string `json:"status" xml:"status"`
	Error  string `json:"error,omitempty" xml:"error,omitempty"`
}

ScanEntry represents a single scanned file entry.

Fields:

  • Rule: The pattern matching rule that identified this file
  • PM: Package manager identifier (e.g., "npm", "pip", "go")
  • Format: File format or type (e.g., "package.json", "requirements.txt")
  • File: Absolute or relative path to the file
  • Status: Current status of the entry (e.g., "valid", "invalid")
  • Error: Error message if the entry failed validation (omitted if empty)

type ScanResult

type ScanResult struct {
	XMLName xml.Name    `json:"-" xml:"scanResult"`
	Summary ScanSummary `json:"summary" xml:"summary"`
	Files   []ScanEntry `json:"files" xml:"files>file"`
}

ScanResult represents the output data for the scan command.

Fields:

  • XMLName: XML root element name (used only for XML marshaling)
  • Summary: Aggregate statistics about the scan operation
  • Files: List of individual file entries discovered during scanning

type ScanSummary

type ScanSummary struct {
	Directory    string `json:"directory" xml:"directory"`
	TotalEntries int    `json:"total_entries" xml:"totalEntries"`
	UniqueFiles  int    `json:"unique_files" xml:"uniqueFiles"`
	RulesMatched int    `json:"rules_matched" xml:"rulesMatched"`
	ValidFiles   int    `json:"valid_files" xml:"validFiles"`
	InvalidFiles int    `json:"invalid_files" xml:"invalidFiles"`
}

ScanSummary holds summary statistics for scan results.

Fields:

  • Directory: The directory path that was scanned
  • TotalEntries: Total number of entries found during the scan
  • UniqueFiles: Number of unique files discovered
  • RulesMatched: Number of pattern matching rules that found matches
  • ValidFiles: Count of files that passed validation
  • InvalidFiles: Count of files that failed validation

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table provides a flexible table formatter with dynamic column widths. It handles Unicode-aware width calculations and consistent formatting.

Fields:

  • columns: List of columns with their headers, widths, and visibility state
  • separator: String used to separate columns in formatted output (default: " ")

func NewTable

func NewTable() *Table

NewTable creates a new table formatter and returns a pointer to it.

The table is initialized with an empty column list and a default separator of two spaces (" ").

Returns:

  • *Table: A new table instance ready for column configuration

func (*Table) AddColumn

func (t *Table) AddColumn(header string) *Table

AddColumn adds a column with the given header and returns the table.

The initial width is set to the display width of the header using Unicode-aware width calculation.

Parameters:

  • header: The text to display in the column header

Returns:

  • *Table: The table instance for method chaining

func (*Table) AddColumnWithMinWidth

func (t *Table) AddColumnWithMinWidth(header string, minWidth int) *Table

AddColumnWithMinWidth adds a column with a minimum width guarantee and returns the table.

The column width will be set to the larger of minWidth or the display width of the header. This is useful for ensuring columns don't become too narrow.

Parameters:

  • header: The text to display in the column header
  • minWidth: Minimum width in characters for this column

Returns:

  • *Table: The table instance for method chaining

func (*Table) AddConditionalColumn

func (t *Table) AddConditionalColumn(header string, visible bool) *Table

AddConditionalColumn adds a column with configurable visibility and returns the table.

This is useful for columns that should only appear when certain data exists, such as a GROUP column that's hidden when no items have group assignments.

Parameters:

  • header: The text to display in the column header
  • visible: Whether the column should be initially visible

Returns:

  • *Table: The table instance for method chaining

func (*Table) Clone

func (t *Table) Clone() *Table

Clone creates a deep copy of the table and returns it.

The cloned table has independent column state, so modifications to the clone do not affect the original table.

Returns:

  • *Table: A new table instance with copied column configuration

func (*Table) ColumnCount

func (t *Table) ColumnCount() int

ColumnCount returns the total number of columns including hidden ones.

Returns:

  • int: Total count of all columns (both visible and hidden)

func (*Table) FormatRow

func (t *Table) FormatRow(values ...string) string

FormatRow formats a data row with proper padding for each column and returns the formatted string.

Values are padded to match their respective column widths. Hidden columns are skipped, but their corresponding values should still be included in the input. Missing values (when fewer values than columns are provided) are treated as empty strings.

Parameters:

  • values: Variable number of strings representing the row data, one per column

Returns:

  • string: Formatted row with values separated by the separator

func (*Table) FormatRowFiltered

func (t *Table) FormatRowFiltered(values ...string) string

FormatRowFiltered formats a row using only visible column values and returns the formatted string.

This method expects that you've already filtered out values for hidden columns. It maps values sequentially to visible columns only.

Parameters:

  • values: Variable number of strings, one for each visible column only

Returns:

  • string: Formatted row with values separated by the separator

func (*Table) Fprint

func (t *Table) Fprint(w io.Writer)

Fprint outputs the table header and separator to the given writer.

Parameters:

  • w: The writer to output to (e.g., os.Stdout, os.Stderr, or a buffer)

func (*Table) GetColumnWidth

func (t *Table) GetColumnWidth(index int) int

GetColumnWidth returns the width of a column by index.

Parameters:

  • index: Zero-based index of the column

Returns:

  • int: The column's width in characters; returns 0 if index is out of bounds

func (*Table) GetColumnWidthByHeader

func (t *Table) GetColumnWidthByHeader(header string) int

GetColumnWidthByHeader returns the width of a column by header name.

Parameters:

  • header: The header text of the column to query

Returns:

  • int: The column's width in characters; returns 0 if no matching column is found

func (*Table) HeaderRow

func (t *Table) HeaderRow() string

HeaderRow returns the formatted header row string.

Hidden columns are excluded from the output. Each header is padded to match its column's width.

Returns:

  • string: Formatted header row with columns separated by the separator

func (*Table) IsColumnHidden

func (t *Table) IsColumnHidden(index int) bool

IsColumnHidden returns whether a column is hidden by index.

Parameters:

  • index: Zero-based index of the column to check

Returns:

  • bool: true if the column is hidden or index is out of bounds; false otherwise

func (*Table) Print

func (t *Table) Print()

Print outputs the table header and separator to stdout.

This is a convenience method for displaying table headers before printing data rows in a loop.

func (*Table) SeparatorRow

func (t *Table) SeparatorRow() string

SeparatorRow returns a separator row with dashes matching column widths.

Hidden columns are excluded. Each separator contains as many dashes as the column's width to create a visual divider between header and data rows.

Returns:

  • string: Formatted separator row with dash sequences separated by the separator

func (*Table) SetColumnVisible

func (t *Table) SetColumnVisible(index int, visible bool) *Table

SetColumnVisible sets the visibility of a column by index and returns the table.

Parameters:

  • index: Zero-based index of the column to modify
  • visible: Whether the column should be visible (true) or hidden (false)

Returns:

  • *Table: The table instance for method chaining

func (*Table) SetColumnVisibleByHeader

func (t *Table) SetColumnVisibleByHeader(header string, visible bool) *Table

SetColumnVisibleByHeader sets the visibility of a column by header name and returns the table.

If multiple columns have the same header, only the first match is affected.

Parameters:

  • header: The header text of the column to modify
  • visible: Whether the column should be visible (true) or hidden (false)

Returns:

  • *Table: The table instance for method chaining

func (*Table) String

func (t *Table) String() string

String returns a string representation of the table structure for debugging.

The output shows all columns with their headers, widths, and visibility state in the format: "Table{columns: [Header1:Width1, Header2:Width2 (hidden), ...]}".

Returns:

  • string: A human-readable representation of the table configuration

func (*Table) UpdateWidth

func (t *Table) UpdateWidth(index int, value string) *Table

UpdateWidth updates a single column's width by index and returns the table.

The column width is only increased if the value's display width is larger than the current width.

Parameters:

  • index: Zero-based index of the column to update
  • value: The string value to measure and potentially expand the column width

Returns:

  • *Table: The table instance for method chaining

func (*Table) UpdateWidths

func (t *Table) UpdateWidths(values ...string) *Table

UpdateWidths updates column widths based on a row of values and returns the table.

It performs the following operations:

  • Step 1: Calculates display width for each value using Unicode-aware measurement
  • Step 2: Compares each value's width with the current column width
  • Step 3: Keeps the larger width to ensure all content fits

Parameters:

  • values: Variable number of strings representing a data row

Returns:

  • *Table: The table instance for method chaining

func (*Table) VisibleColumnCount

func (t *Table) VisibleColumnCount() int

VisibleColumnCount returns the number of visible columns.

Returns:

  • int: Count of columns that are not hidden

func (*Table) WithSeparator

func (t *Table) WithSeparator(sep string) *Table

WithSeparator sets a custom column separator and returns the table.

Parameters:

  • sep: The string to use between columns (e.g., " | " for pipe-separated output)

Returns:

  • *Table: The table instance for method chaining

type UpdatePackage

type UpdatePackage struct {
	Rule             string `json:"rule" xml:"rule"`
	PM               string `json:"pm" xml:"pm"`
	Type             string `json:"type" xml:"type"`
	Constraint       string `json:"constraint" xml:"constraint"`
	Version          string `json:"version" xml:"version"`
	InstalledVersion string `json:"installed_version" xml:"installedVersion"`
	Target           string `json:"target" xml:"target"`
	Status           string `json:"status" xml:"status"`
	Group            string `json:"group,omitempty" xml:"group,omitempty"`
	Name             string `json:"name" xml:"name"`
	Error            string `json:"error,omitempty" xml:"error,omitempty"`
}

UpdatePackage represents a package entry in the update output.

Fields:

  • Rule: The pattern matching rule that identified this package
  • PM: Package manager identifier (e.g., "npm", "pip", "go")
  • Type: Package type (e.g., "direct", "dev", "peer")
  • Constraint: Version constraint specified in the dependency file
  • Version: Latest available version
  • InstalledVersion: Currently installed version before update
  • Target: Target version for the update
  • Status: Current status (e.g., "updated", "failed", "skipped")
  • Group: Optional grouping identifier (omitted if empty)
  • Name: Package name
  • Error: Error message if the update failed (omitted if empty)

type UpdateResult

type UpdateResult struct {
	XMLName  xml.Name        `json:"-" xml:"updateResult"`
	Summary  UpdateSummary   `json:"summary" xml:"summary"`
	Packages []UpdatePackage `json:"packages" xml:"packages>package"`
	Warnings []string        `json:"warnings,omitempty" xml:"warnings>warning,omitempty"`
	Errors   []string        `json:"errors,omitempty" xml:"errors>error,omitempty"`
}

UpdateResult represents the output data for the update command.

Fields:

  • XMLName: XML root element name (used only for XML marshaling)
  • Summary: Aggregate statistics about the update operation
  • Packages: List of package entries with update information
  • Warnings: Warning messages generated during the update operation (omitted if empty)
  • Errors: Error messages generated during the update operation (omitted if empty)

type UpdateSummary

type UpdateSummary struct {
	TotalPackages   int  `json:"total_packages" xml:"totalPackages"`
	UpdatedPackages int  `json:"updated_packages" xml:"updatedPackages"`
	FailedPackages  int  `json:"failed_packages" xml:"failedPackages"`
	DryRun          bool `json:"dry_run" xml:"dryRun"`
}

UpdateSummary holds summary statistics for update results.

Fields:

  • TotalPackages: Total number of packages processed
  • UpdatedPackages: Number of packages successfully updated
  • FailedPackages: Number of packages that failed to update
  • DryRun: Whether this was a dry-run (no actual updates performed)

Jump to

Keyboard shortcuts

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