list

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package list provides functionality for listing and formatting changes and specifications in various output formats.

Package list provides functionality for listing and formatting changes and specifications. This file handles unified formatting for displaying both changes and specs together.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatAllJSON

func FormatAllJSON(
	items ItemList,
) (string, error)

FormatAllJSON formats all items as a JSON array. Each item includes its type (change or spec) along with all relevant fields. Items are sorted by ID before serialization. Returns an empty JSON array if no items are provided.

func FormatAllLong

func FormatAllLong(items ItemList) string

FormatAllLong formats all items with detailed information. Shows ID, type, title, and relevant counts (deltas/tasks for changes, requirements for specs). Items are sorted by ID.

func FormatAllText

func FormatAllText(items ItemList) string

FormatAllText formats all items (changes and specs) as text with type indicators. Items are sorted by ID and displayed with their type and relevant details (tasks for changes, requirements for specs).

func FormatChangesJSON

func FormatChangesJSON(
	changes []ChangeInfo,
) (string, error)

FormatChangesJSON formats changes as JSON array

func FormatChangesLong

func FormatChangesLong(
	changes []ChangeInfo,
) string

FormatChangesLong formats changes with detailed information

func FormatChangesText

func FormatChangesText(
	changes []ChangeInfo,
) string

FormatChangesText formats changes as simple text list (IDs only)

func FormatSpecsJSON

func FormatSpecsJSON(
	specs []SpecInfo,
) (string, error)

FormatSpecsJSON formats specs as JSON array

func FormatSpecsLong

func FormatSpecsLong(specs []SpecInfo) string

FormatSpecsLong formats specs with detailed information

func FormatSpecsText

func FormatSpecsText(specs []SpecInfo) string

FormatSpecsText formats specs as simple text list (IDs only)

func RunInteractiveAll

func RunInteractiveAll(
	items ItemList,
	projectPath string,
	stdoutMode bool,
) error

RunInteractiveAll runs the interactive table for all items (changes and specs)

func RunInteractiveArchive

func RunInteractiveArchive(
	changes []ChangeInfo,
	projectPath string,
) (string, error)

RunInteractiveArchive runs the interactive table for archive selection. Returns the selected change ID or empty string if cancelled

func RunInteractiveChanges

func RunInteractiveChanges(
	changes []ChangeInfo,
	projectPath string,
	stdoutMode bool,
) (archiveID, prID string, err error)

RunInteractiveChanges runs the interactive table for changes. Returns (archiveID, prID, error):

  • archiveID is set if archive was requested via 'a' key
  • prID is set if PR mode was requested via 'P' key
  • Both are empty if user quit or cancelled

func RunInteractiveSpecs

func RunInteractiveSpecs(
	specs []SpecInfo,
	projectPath string,
	stdoutMode bool,
) error

RunInteractiveSpecs runs the interactive table for specs

Types

type ChangeInfo

type ChangeInfo struct {
	ID         string             `json:"id"`
	Title      string             `json:"title"`
	DeltaCount int                `json:"deltaCount"`
	TaskStatus parsers.TaskStatus `json:"taskStatus"`
}

ChangeInfo represents information about a change

func FilterChangesNotOnRef

func FilterChangesNotOnRef(
	changes []ChangeInfo,
	ref string,
) ([]ChangeInfo, error)

FilterChangesNotOnRef filters the given changes to only include those whose paths do NOT exist on the specified git ref. This is useful for identifying unmerged changes that haven't been merged to the main branch yet. The ref should be a full ref like "origin/main" or "origin/master".

type ColumnPriority added in v0.0.7

type ColumnPriority int

ColumnPriority defines the priority level for table columns. Higher priority columns are shown first when space is limited.

const (
	// ColumnPriorityEssential - always shown (ID column)
	ColumnPriorityEssential ColumnPriority = iota
	// ColumnPriorityHigh - always shown, width may be adjusted (Title, Type)
	ColumnPriorityHigh
	// ColumnPriorityMedium - hidden below narrow breakpoint (Deltas, Requirements)
	ColumnPriorityMedium
	// ColumnPriorityLow - hidden below medium breakpoint (Tasks, Details)
	ColumnPriorityLow
)

type Item

type Item struct {
	// Type indicates whether this item is a change or spec
	Type ItemType `json:"type"`
	// Change contains the change information if Type == ItemTypeChange
	Change *ChangeInfo `json:"change,omitempty"`
	// Spec contains the spec information if Type == ItemTypeSpec
	Spec *SpecInfo `json:"spec,omitempty"`
}

Item represents a unified wrapper around either a ChangeInfo or SpecInfo. Exactly one of Change or Spec will be non-nil, determined by Type.

func NewChangeItem

func NewChangeItem(change ChangeInfo) Item

NewChangeItem creates a new Item wrapping a ChangeInfo

func NewSpecItem

func NewSpecItem(spec SpecInfo) Item

NewSpecItem creates a new Item wrapping a SpecInfo

func (*Item) ID

func (i *Item) ID() string

ID returns the identifier for this item (change ID or spec ID)

func (*Item) Title

func (i *Item) Title() string

Title returns the title for this item

type ItemList

type ItemList []Item

ItemList represents a collection of mixed changes and specs

func (ItemList) Changes

func (il ItemList) Changes() []ChangeInfo

Changes returns all ChangeInfo items from the list

func (ItemList) FilterByType

func (il ItemList) FilterByType(
	itemType ItemType,
) ItemList

FilterByType returns a new ItemList containing only items of the specified type.

func (ItemList) Specs

func (il ItemList) Specs() []SpecInfo

Specs returns all SpecInfo items from the list

type ItemType

type ItemType int

ItemType represents the type of an item (change or spec)

const (
	// ItemTypeChange represents a change item
	ItemTypeChange ItemType = iota
	// ItemTypeSpec represents a spec item
	ItemTypeSpec
)

func (ItemType) String

func (it ItemType) String() string

String returns the string representation of an ItemType

type ListAllOptions

type ListAllOptions struct {
	// FilterType specifies which types to include (nil = all types)
	FilterType *ItemType
	// SortByID sorts items alphabetically by ID (default: true)
	SortByID bool
}

ListAllOptions contains optional filtering and sorting parameters for ListAll

type Lister

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

Lister handles listing operations for changes and specs

func NewLister

func NewLister(projectPath string) *Lister

NewLister creates a new Lister for the given project path

func (*Lister) ListAll

func (l *Lister) ListAll(
	opts *ListAllOptions,
) (ItemList, error)

ListAll retrieves all changes and specs as a unified ItemList

func (*Lister) ListChanges

func (l *Lister) ListChanges() ([]ChangeInfo, error)

ListChanges retrieves information about all active changes

func (*Lister) ListSpecs

func (l *Lister) ListSpecs() ([]SpecInfo, error)

ListSpecs retrieves information about all specs

type SpecInfo

type SpecInfo struct {
	ID               string `json:"id"`
	Title            string `json:"title"`
	RequirementCount int    `json:"requirementCount"`
}

SpecInfo represents information about a spec

Jump to

Keyboard shortcuts

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