records

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AdrStatusDescriptions = map[AdrStatus]string{
	UNKNOWN:    "status is not determined",
	PROPOSED:   "the record has been proposed but is not accepted yet by stakeholders",
	ACCEPTED:   "the record has been accepted by stakeholders",
	DEPRECATED: "the decision record is deprecated and no longer applies",
	SUPERSEDED: "the decision record has been superseded by a new one",
	OBSERVED:   "documents a pre-existing decision reconstructed after the fact, e.g. while making sense of legacy code you did not write",
}

AdrStatusDescriptions documents the meaning of each status.

AdrStatuses lists every allowed status in display order.

Functions

func AllowedStatuses

func AllowedStatuses() string

AllowedStatuses returns the allowed statuses formatted for help/error messages, e.g. `"unknown", "proposed", "accepted", "deprecated", "superseded" or "observed"`.

func LoadConfig added in v0.2.0

func LoadConfig() (cs.Config, string, error)

LoadConfig finds the nearest configuration file and returns the parsed config along with the directory that contains it (used to resolve relative paths).

func MarshalYAML

func MarshalYAML(v any) ([]byte, error)

func StatusHelp added in v0.2.0

func StatusHelp() string

StatusHelp returns a multi-line block listing each status and its meaning, suitable for appending to a command's help description.

Types

type AdrData

type AdrData struct {
	ID             string      `yaml:"id" json:"id"`
	Title          string      `yaml:"title" json:"title"`
	Author         string      `yaml:"author" json:"author"`
	Status         AdrStatus   `yaml:"status" json:"status"`
	CreationDate   time.Time   `yaml:"creation_date" mapstructure:"creation_date" json:"creation_date"`
	LastUpdateDate time.Time   `yaml:"last_update_date" mapstructure:"last_update_date" json:"last_update_date"`
	Tags           Set[string] `yaml:"tags,omitempty" json:"tags,omitempty"`
	Superseders    Set[string] `yaml:"superseders,omitempty" json:"superseders,omitempty"`

	Name string `yaml:"-" json:"file"`
	Body string `yaml:"-" json:"-"`
}

func (AdrData) ToRow

func (a AdrData) ToRow() []string

type AdrStatus

type AdrStatus string

AdrStatus type

const (
	UNKNOWN    AdrStatus = "unknown"
	PROPOSED   AdrStatus = "proposed"
	ACCEPTED   AdrStatus = "accepted"
	DEPRECATED AdrStatus = "deprecated"
	SUPERSEDED AdrStatus = "superseded"
	OBSERVED   AdrStatus = "observed"
)

ADR status enums

func ParseStatus

func ParseStatus(v string) (AdrStatus, error)

ParseStatus validates a raw value and returns the matching AdrStatus.

func (AdrStatus) Colorized

func (e AdrStatus) Colorized() string

Colorized returns the AdrStatus as a colored string

func (AdrStatus) String

func (e AdrStatus) String() string

String is used by fmt.Print and everywhere a status is rendered as text.

type Service

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

func NewService

func NewService() (*Service, error)

func (Service) CreateRecord

func (s Service) CreateRecord(title string, record AdrData, body string) (AdrData, error)

CreateRecord writes a new record file. body is the markdown of the sections (a template skeleton or a caller-provided, already-validated body); the record envelope (front-matter, title and date) is added here.

func (Service) DefaultAuthor added in v0.2.0

func (s Service) DefaultAuthor() string

DefaultAuthor returns the author configured as default ("" if unset).

func (Service) DefaultTemplate added in v0.2.0

func (s Service) DefaultTemplate() string

DefaultTemplate returns the template configured as default ("" if unset).

func (Service) GetRecord

func (s Service) GetRecord(recordID string) (AdrData, bool)

func (Service) GetRecords

func (s Service) GetRecords() []AdrData

func (Service) RecordPath added in v0.2.0

func (s Service) RecordPath(record AdrData) string

RecordPath returns the absolute path of a record's file.

func (Service) TemplatesDir added in v0.2.0

func (s Service) TemplatesDir() string

TemplatesDir returns the resolved custom templates directory ("" if unset).

func (Service) UpdateRecord

func (s Service) UpdateRecord(record AdrData) error

type Set

type Set[T cmp.Ordered] map[T]bool

func (*Set[T]) Append

func (s *Set[T]) Append(elements ...T)

func (Set[T]) MarshalJSON added in v0.2.0

func (s Set[T]) MarshalJSON() ([]byte, error)

func (Set[T]) MarshalYAML

func (s Set[T]) MarshalYAML() (interface{}, error)

func (Set[T]) Remove

func (s Set[T]) Remove(elements ...T)

func (*Set[T]) Set

func (s *Set[T]) Set(elements ...T)

func (Set[T]) ToSlice

func (s Set[T]) ToSlice() []T

func (*Set[T]) UnmarshalYAML

func (s *Set[T]) UnmarshalYAML(unmarshal func(interface{}) error) error

Jump to

Keyboard shortcuts

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