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

api

package
v0.1.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OptionColors

func OptionColors(data *BoardData) map[string]map[string]string

OptionColors builds a lookup map of fieldName → optionName → terminal color string derived from each option's GitHub color enum. Used by the board renderer.

Types

type BoardData

type BoardData struct {
	Views  []ProjectView
	Fields []SelectField
	Items  []RawItem
}

BoardData holds everything fetched from a project in one call. Grouping into columns is done client-side via GroupByField.

type Card

type Card struct {
	ID          string
	Type        string // ISSUE | PULL_REQUEST | DRAFT_ISSUE
	Number      int
	Title       string
	State       string
	URL         string
	Repo        string
	Assignees   []string
	Labels      []Label
	Status      string
	Body        string
	FieldValues map[string]string // all field values keyed by field name
}

Card is a single item on the board.

func FlatItems

func FlatItems(data *BoardData) []Card

FlatItems returns all non-archived items in API order, for table views.

type Client

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

Client wraps the go-gh GraphQL client.

func NewClient

func NewClient() (*Client, error)

NewClient creates a Client using the current gh auth context.

func (*Client) GetProjectBoard

func (c *Client) GetProjectBoard(projectID string) (*BoardData, error)

GetProjectBoard fetches views, fields, and all items for a project. Use GroupByField to render a specific view's columns.

func (*Client) ListOrgProjects

func (c *Client) ListOrgProjects(org string) ([]Project, error)

ListOrgProjects fetches up to 50 open projects for the given org login.

func (*Client) ListUserProjects

func (c *Client) ListUserProjects(login string) ([]Project, error)

ListUserProjects fetches up to 50 open projects for the given user login.

func (*Client) ListViewerOrgs

func (c *Client) ListViewerOrgs() ([]string, error)

ListViewerOrgs returns the login names of orgs the authenticated user belongs to.

func (*Client) ViewerLogin

func (c *Client) ViewerLogin() (string, error)

ViewerLogin returns the authenticated user's login.

type Column

type Column struct {
	Name  string
	Cards []Card
}

Column is a named group of cards on a board view.

func GroupByField

func GroupByField(data *BoardData, fieldName string) []Column

GroupByField buckets RawItems into Columns using the named single-select field. Column order follows the field's option order. Falls back to "No <field>" bucket.

type FieldOption

type FieldOption struct {
	Name  string
	Color string // GitHub enum: GRAY | BLUE | GREEN | YELLOW | ORANGE | RED | PINK | PURPLE
}

FieldOption is one option of a single-select field, including its GitHub color enum.

type Label

type Label struct {
	Name  string
	Color string // hex color without '#', e.g. "d73a4a"
}

Label holds a GitHub issue label with its display color.

type Project

type Project struct {
	ID          string
	Number      int
	Title       string
	Owner       string
	Description string
	URL         string
	UpdatedAt   string
}

Project represents a GitHub Projects v2 project.

type ProjectView

type ProjectView struct {
	ID            string
	Name          string
	Layout        string // BOARD_LAYOUT | TABLE_LAYOUT | ROADMAP_LAYOUT
	GroupByField  string
	VisibleFields []VisibleField
}

ProjectView mirrors a saved view from GitHub Projects v2.

type RawItem

type RawItem struct {
	ID          string
	Type        string
	IsArchived  bool
	Number      int
	Title       string
	State       string
	URL         string
	Repo        string
	Assignees   []string
	Labels      []Label
	Body        string
	FieldValues map[string]string // field name → selected option name
}

RawItem is an ungrouped project item with all its field values.

type SelectField

type SelectField struct {
	ID      string
	Name    string
	Options []FieldOption
}

SelectField is a single-select field with ordered options.

type VisibleField

type VisibleField struct {
	ID       string
	Name     string
	DataType string // TITLE | ASSIGNEES | SINGLE_SELECT | DATE | NUMBER | TEXT | ITERATION | MILESTONE | REPOSITORY | LABELS | LINKED_PULL_REQUESTS
}

VisibleField is a field configured to be shown in a view.

Jump to

Keyboard shortcuts

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