Documentation
¶
Index ¶
- Variables
- func AllowedStatuses() string
- func LoadConfig() (cs.Config, string, error)
- func MarshalYAML(v any) ([]byte, error)
- func StatusHelp() string
- type AdrData
- type AdrStatus
- type Service
- func (s Service) CreateRecord(title string, record AdrData, body string) (AdrData, error)
- func (s Service) DefaultAuthor() string
- func (s Service) DefaultTemplate() string
- func (s Service) GetRecord(recordID string) (AdrData, bool)
- func (s Service) GetRecords() []AdrData
- func (s Service) RecordPath(record AdrData) string
- func (s Service) TemplatesDir() string
- func (s Service) UpdateRecord(record AdrData) error
- type Set
- func (s *Set[T]) Append(elements ...T)
- func (s Set[T]) MarshalJSON() ([]byte, error)
- func (s Set[T]) MarshalYAML() (interface{}, error)
- func (s Set[T]) Remove(elements ...T)
- func (s *Set[T]) Set(elements ...T)
- func (s Set[T]) ToSlice() []T
- func (s *Set[T]) UnmarshalYAML(unmarshal func(interface{}) error) error
Constants ¶
This section is empty.
Variables ¶
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.
var AdrStatuses = []AdrStatus{UNKNOWN, PROPOSED, ACCEPTED, DEPRECATED, SUPERSEDED, OBSERVED}
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
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 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:"-"`
}
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 ¶
ParseStatus validates a raw value and returns the matching AdrStatus.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func (Service) CreateRecord ¶
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
DefaultAuthor returns the author configured as default ("" if unset).
func (Service) DefaultTemplate ¶ added in v0.2.0
DefaultTemplate returns the template configured as default ("" if unset).
func (Service) GetRecords ¶
func (Service) RecordPath ¶ added in v0.2.0
RecordPath returns the absolute path of a record's file.
func (Service) TemplatesDir ¶ added in v0.2.0
TemplatesDir returns the resolved custom templates directory ("" if unset).