workitem

package
v0.4.0 Latest Latest
Warning

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

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

Documentation

Overview

Package workitem provides a provider-agnostic abstraction for interacting with project management items like issues, tasks, and user stories.

The core of this package is the Provider interface, which defines a standard set of operations (e.g., List, Get, Create) for work items. Concrete implementations, such as one for the GitHub API, will satisfy this interface.

This decoupling allows the CLI commands to operate on the generic WorkItem struct without needing to know the specifics of the backend (GitHub, GitLab, etc.), making the system extensible.

internal/workitem/provider.go

internal/workitem/types.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comment

type Comment struct {
	Author    string
	Body      string
	CreatedAt time.Time
	URL       string
}

Comment represents a single comment on a work item.

type Label

type Label struct {
	Name        string
	Description string
	Color       string
}

Label represents a label that can be applied to a work item.

type ListOptions

type ListOptions struct {
	State    State
	Labels   []string
	Assignee string
	Limit    int
	Page     int
}

ListOptions provides filters and pagination for listing work items.

type Provider

type Provider interface {
	// ListItems retrieves a collection of work items based on the provided options.
	ListItems(ctx context.Context, options ListOptions) ([]WorkItem, error)

	// GetItem retrieves a single work item by its public number, optionally fetching comments.
	GetItem(ctx context.Context, number int, withComments bool) (*WorkItem, error)

	// CreateItem creates a new work item in the backend system.
	CreateItem(ctx context.Context, item WorkItem) (*WorkItem, error)

	// UpdateItem updates an existing work item in the backend system.
	UpdateItem(ctx context.Context, number int, item WorkItem) (*WorkItem, error)

	// SearchItems uses a provider-specific query string to find work items.
	SearchItems(ctx context.Context, query string) ([]WorkItem, error)

	// CreateLabel creates a new label in the backend system.
	CreateLabel(ctx context.Context, label Label) (*Label, error)
}

Provider defines the interface for a work item management system. This allows for abstracting the backend (GitHub, GitLab, etc.).

type State

type State string

State represents the status of a work item (e.g., Open, Closed).

const (
	StateOpen   State = "Open"
	StateClosed State = "Closed"
)

type Type

type Type string

Type represents the classification of a work item (e.g., Story, Task).

const (
	TypeStory Type = "Story"
	TypeTask  Type = "Task"
	TypeEpic  Type = "Epic"
	TypeBug   Type = "Bug"
	TypeChore Type = "Chore"
)

type WorkItem

type WorkItem struct {
	// Provider-specific ID (e.g., GitHub's GraphQL node ID).
	ID string
	// Publicly visible number for the item (e.g., GitHub issue #123).
	Number int
	// The title or summary of the work item.
	Title string
	// The detailed description or body of the work item.
	Body string
	// The current state of the item.
	State State
	// The classification of the item.
	Type Type
	// The web URL to view the item in its native system.
	URL string
	// The username of the author.
	Author string
	// A list of associated labels or tags.
	Labels []string
	// A list of usernames assigned to the item.
	Assignees []string
	// When the item was created.
	CreatedAt time.Time
	// When the item was last updated.
	UpdatedAt time.Time
	// A list of comments on the item.
	Comments []Comment
	// A slice of child work items to represent a hierarchy.
	Children []*WorkItem
}

WorkItem is the generic, provider-agnostic representation of a work item. It includes a Children slice to allow for building hierarchical trees.

Directories

Path Synopsis
internal/workitem/github/provider.go
internal/workitem/github/provider.go
internal/workitem/resolver/resolver.go
internal/workitem/resolver/resolver.go

Jump to

Keyboard shortcuts

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