formatter

package
v0.0.0-...-121be0d Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AvailableColumns = map[string]Column{
	"index": {
		ID:          "index",
		Header:      "#",
		Description: "Row number",
		GetValue: func(pr models.PullRequest, index int, org, project string) string {
			return fmt.Sprintf("%d", index)
		},
	},
	"id": {
		ID:          "id",
		Header:      "PR ID",
		Description: "Pull request ID",
		GetValue: func(pr models.PullRequest, index int, org, project string) string {
			return fmt.Sprintf("%d", pr.ID)
		},
	},
	"repo": {
		ID:          "repo",
		Header:      "REPO NAME",
		Description: "Repository name",
		GetValue: func(pr models.PullRequest, index int, org, project string) string {
			return pr.Repository.Name
		},
	},
	"title": {
		ID:          "title",
		Header:      "PR NAME",
		Description: "Pull request title",
		GetValue: func(pr models.PullRequest, index int, org, project string) string {
			return pr.Title
		},
	},
	"author": {
		ID:          "author",
		Header:      "AUTHOR",
		Description: "PR author display name",
		GetValue: func(pr models.PullRequest, index int, org, project string) string {
			return pr.CreatedBy.DisplayName
		},
	},
	"status": {
		ID:          "status",
		Header:      "STATUS",
		Description: "PR status (active, completed, abandoned)",
		GetValue: func(pr models.PullRequest, index int, org, project string) string {
			return pr.Status
		},
	},
	"created": {
		ID:          "created",
		Header:      "CREATED DATE",
		Description: "Date when PR was created",
		GetValue: func(pr models.PullRequest, index int, org, project string) string {
			if pr.CreationDate.IsZero() {
				return "N/A"
			}
			return pr.CreationDate.Format("2006-01-02 15:04:05")
		},
	},
	"completed": {
		ID:          "completed",
		Header:      "COMPLETION DATE",
		Description: "Date when PR was completed/closed",
		GetValue: func(pr models.PullRequest, index int, org, project string) string {
			if pr.ClosedDate.IsZero() {
				return "N/A"
			}
			return pr.ClosedDate.Format("2006-01-02 15:04:05")
		},
	},
	"source": {
		ID:          "source",
		Header:      "SOURCE BRANCH",
		Description: "Source branch name",
		GetValue: func(pr models.PullRequest, index int, org, project string) string {
			return strings.TrimPrefix(pr.SourceRefName, "refs/heads/")
		},
	},
	"target": {
		ID:          "target",
		Header:      "TARGET BRANCH",
		Description: "Target branch name",
		GetValue: func(pr models.PullRequest, index int, org, project string) string {
			return strings.TrimPrefix(pr.TargetRefName, "refs/heads/")
		},
	},
	"merge_status": {
		ID:          "merge_status",
		Header:      "MERGE STATUS",
		Description: "Merge status (succeeded, conflicts, etc.)",
		GetValue: func(pr models.PullRequest, index int, org, project string) string {
			return pr.MergeStatus
		},
	},
	"url": {
		ID:          "url",
		Header:      "PR URL",
		Description: "Web URL to the pull request",
		GetValue: func(pr models.PullRequest, index int, org, project string) string {
			return pr.GetWebURL(org, project)
		},
	},
	"link": {
		ID:          "link",
		Header:      "PR LINK",
		Description: "Clickable hyperlink (for XLSX)",
		GetValue: func(pr models.PullRequest, index int, org, project string) string {
			return fmt.Sprintf("LINK TO PR (#%d)", pr.ID)
		},
	},
}
View Source
var ColumnOrder = []string{
	"index", "id", "repo", "title", "author", "status",
	"created", "completed", "source", "target", "merge_status", "url", "link",
}
View Source
var DefaultColumns = "index,repo,title,completed,url,link"

Functions

func ListColumns

func ListColumns() string

Types

type CSVFormatter

type CSVFormatter struct{}

func NewCSVFormatter

func NewCSVFormatter() *CSVFormatter

func (*CSVFormatter) Format

func (f *CSVFormatter) Format(prs []models.PullRequest, dateFormat string, options map[string]string) (string, error)

type Column

type Column struct {
	ID          string
	Header      string
	Description string
	GetValue    func(pr models.PullRequest, index int, org, project string) string
}

func ParseColumns

func ParseColumns(columnsStr string) ([]Column, error)

type DOCXFormatter

type DOCXFormatter struct{}

func NewDOCXFormatter

func NewDOCXFormatter() *DOCXFormatter

func (*DOCXFormatter) Format

func (f *DOCXFormatter) Format(prs []models.PullRequest, dateFormat string, options map[string]string) ([]byte, error)

type Formatter

type Formatter interface {
	Format(prs []models.PullRequest, dateFormat string, options map[string]string) (string, error)
}

type JSONFormatter

type JSONFormatter struct{}

func NewJSONFormatter

func NewJSONFormatter() *JSONFormatter

func (*JSONFormatter) Format

func (f *JSONFormatter) Format(prs []models.PullRequest, dateFormat string, options map[string]string) (string, error)

type TableFormatter

type TableFormatter struct{}

func NewTableFormatter

func NewTableFormatter() *TableFormatter

func (*TableFormatter) Format

func (f *TableFormatter) Format(prs []models.PullRequest, dateFormat string, options map[string]string) (string, error)

type XLSXFormatter

type XLSXFormatter struct{}

func NewXLSXFormatter

func NewXLSXFormatter() *XLSXFormatter

func (*XLSXFormatter) Format

func (f *XLSXFormatter) Format(prs []models.PullRequest, dateFormat string, options map[string]string) ([]byte, error)

Jump to

Keyboard shortcuts

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