todo

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: BSD-2-Clause Imports: 9 Imported by: 1

Documentation

Overview

Package todo provides easy API access to Sourcehut issue trackers.

Index

Examples

Constants

View Source
const BaseURL = "https://todo.sr.ht/api/"

BaseURL is the default public Sourcehut issue trackers API URL. It is exported for convenience.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client handles communication with the issue tracker related methods of the Sourcehut API.

API docs: https://man.sr.ht/todo.sr.ht/api.md

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient returns a new API client.

func (*Client) GetUser

func (c *Client) GetUser(username string) (sourcehut.User, error)

GetUser returns information about the provided username, or the currently authenticated user if the username is empty.

func (*Client) NewTracker

func (c *Client) NewTracker(name, description string) (*Tracker, error)

NewTracker creates and returns a new repository from the provided template.

func (*Client) Tracker

func (c *Client) Tracker(username, tracker string) (*Tracker, error)

Tracker returns information about a specific issue tracker owned by the provided username. If an empty username is provided, the authenticated user is used.

func (*Client) Trackers

func (c *Client) Trackers(username string) (TrackerIter, error)

Trackers returns an iterator over all issue trackers owned by the provided username. If an empty username is provided, the authenticated user is used.

func (*Client) Version

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

Version returns the version of the API.

API docs: https://man.sr.ht/api-conventions.md#get-apiversion

type Option

type Option func(*Client) error

Option is used to configure an API client.

func Base

func Base(base string) Option

Base returns an option that configures the public Sourcehut API URL.

If base does not have a trailing slash, one is added automatically. If unspecified, BaseURL is used.

func SrhtClient

func SrhtClient(client sourcehut.Client) Option

SrhtClient returns an option that configures the client to use the provided sourcehut.Client for API requests. If unspecified, a default sourcehut.Client (with no options of its own) is used.

type ShortTracker

type ShortTracker struct {
	Name    string              `json:"name"`
	Owner   sourcehut.ShortUser `json:"owner"`
	Created time.Time           `json:"created"`
	Updated time.Time           `json:"updated"`
}

ShortTracker represents the unexpanded form of an issue tracker.

type Tracker

type Tracker struct {
	ShortTracker

	Desc  string `json:"description"`
	Perms struct {
		Anonymous []string `json:"anonymous"`
		Submitter []string `json:"submitter"`
		User      []string `json:"user"`
	} `json:"default_permissions"`
}

Tracker represents the expanded form of an issue tracker.

type TrackerIter

type TrackerIter struct {
	*sourcehut.Iter
}

TrackerIter is used for iterating over a collection of issue trackers.

Example
srhtClient := sourcehut.NewClient(sourcehut.Token("<personal access token>"))
todoClient, _ := todo.NewClient(todo.SrhtClient(srhtClient))

iter, _ := todoClient.Trackers("~sircmpwn")
for iter.Next() {
	p := iter.Tracker()
	log.Printf("Tracker %s: %s\n", p.Name, p.Desc)
}
if err := iter.Err(); err != nil {
	log.Fatalf("Error fetching posts: %q", err)
}

func (TrackerIter) Tracker

func (i TrackerIter) Tracker() *Tracker

Tracker returns the issue tracker which the iterator is currently pointing to.

Jump to

Keyboard shortcuts

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