Documentation ¶
Index ¶
- Constants
- Variables
- func AdjustCell(text string, width int) string
- func CommandAdd(conf Config, cmdLine CmdLine) error
- func CommandDashboard(conf Config, cmdLine CmdLine) error
- func CommandDelete(conf Config, cmdLine CmdLine) error
- func CommandEdit(conf Config, cmdLine CmdLine) error
- func CommandHelp(args []string) error
- func CommandInit(conf Config, cmdLine CmdLine) error
- func CommandReview(conf Config, cmdLine CmdLine) error
- func CommandVersion() error
- func DeduplicateStrings(strings []string) []string
- func EnsureRepoExists(repoPath string) error
- func GetValidConfidenceValue(text string) (value float64, err error)
- func GetValidJudgementValue(text string) (string, error)
- func HelpSwitch(args []string) error
- func IsValidConfidenceValue(c float64) bool
- func IsValidStatus(s string) error
- func IsValidUUIDv4String(str string) bool
- func MaxInt(vals []int) (index int, max int)
- func MustEditBytes(data []byte, extension string) ([]byte, error)
- func MustGetTermSize() (int, int, error)
- func MustGetUUID4String() string
- func RunCmd(name string, args ...string) error
- func StrSliceContains(haystack []string, needle string) bool
- func StrSliceContainsAll(subset, superset []string) bool
- func SumInts(vals ...int) int
- type CmdLine
- type Config
- type Decision
- type DecisionSet
- type DecisionSetOpt
- type DecisionSetOpts
- type IdsMap
- type RowStyle
- type Table
Constants ¶
const ( VERSION = "0.1.1" CMD_INIT = "init" CMD_EDIT = "edit" CMD_ADD = "add" CMD_HELP = "help" CMD_VERSION = "version" CMD_REVIEW = "review" CMD_DELETE = "delete" STATUS_PENDING = "pending" // to review STATUS_REVIEWED = "reviewed" // reviewed, may re-review later STATUS_DELETED = "deleted" // moved to deleted folder TABLE_MAX_WIDTH = 160 TABLE_COL_GAP = 2 ANSI_CODE_HEADER = 1 // Bold the header by default UUIDv4_LEN = 36 // TODO After implementing status, rename this constant MAX_DECISIONS = 10000 )
const ( HelpGeneral = `` /* 373-byte string literal not displayed */ HelpVersion = `Usage: klein version Prints semantic version of binary Example: $ klein version v0.2.0 ` HelpAdd = `` /* 589-byte string literal not displayed */ HelpEdit = `` /* 169-byte string literal not displayed */ HelpDelete = `` /* 312-byte string literal not displayed */ HelpReview = `` /* 352-byte string literal not displayed */ )
Variables ¶
var ALL_CMDS = []string{ CMD_INIT, CMD_EDIT, CMD_ADD, CMD_HELP, CMD_VERSION, CMD_REVIEW, CMD_DELETE, CMD_HELP, }
var ALL_STATUSES = []string{ STATUS_PENDING, STATUS_REVIEWED, STATUS_DELETED, }
var NON_RESOLVED_STATUSES = []string{ STATUS_PENDING, STATUS_REVIEWED, }
Functions ¶
func AdjustCell ¶
format cell text to conform to the specified width
func CommandAdd ¶
func CommandDashboard ¶
Print a tree style dashboard of unresolved decisions Default command
func CommandDelete ¶
func CommandEdit ¶
Edit a decision using an editor
func CommandHelp ¶ added in v1.0.0
func CommandInit ¶
Create data dir and init git repository
func CommandReview ¶
func CommandVersion ¶ added in v1.0.0
func CommandVersion() error
func DeduplicateStrings ¶
func EnsureRepoExists ¶
func GetValidConfidenceValue ¶
func GetValidJudgementValue ¶
func HelpSwitch ¶ added in v1.0.0
func IsValidConfidenceValue ¶
func IsValidStatus ¶
func IsValidUUIDv4String ¶
func MustGetTermSize ¶
func MustGetUUID4String ¶
func MustGetUUID4String() string
func StrSliceContains ¶
func StrSliceContainsAll ¶
Return true iff superset contains entire subset
Types ¶
type CmdLine ¶
type CmdLine struct { Cmd string IDs []int Tags []string Confidence float64 Text string Judgement string Reason string Review string Status string Description string }
Struct of all possible elements in a command line (after the command itself)
func ParseCmdLine ¶
type Config ¶
type Decision ¶
type Decision struct { // not stored in file -- rather filename and directory UUID string `yaml:"-"` // yaml ignores this field Status string `yaml:",omitempty"` // show status when editing via edit command // is new or has changed. Need to write to disk. WritePending bool `yaml:"-"` // Mark decision for deletion Deleted bool `yaml:"-"` // ephemeral ID int `yaml:"-"` Decision string Description string `yaml:",omitempty"` Confidence float64 Tags []string Reason string `yaml:",omitempty"` // Use string so that "false" judgements are also written to reviewed decisions Judgement string `yaml:",omitempty"` Review string `yaml:",omitempty"` Created time.Time Reviewed time.Time `yaml:",omitempty"` // contains filtered or unexported fields }
Decisions are statements that are "backed" (that is, associated with) predictions. Computationally this means that it contains a list of predictions.
func UnmarshalDecision ¶
Unmarshall a Decision, given a YAML file path
func (*Decision) DeleteCopies ¶
func (*Decision) NormaliseFields ¶
func (d *Decision) NormaliseFields()
Mutate and sort fields to a common format Makes git diffs more useful
func (*Decision) SaveToDisk ¶
func (*Decision) ValidateFields ¶
TODO Add more validation for fields if necessary here
type DecisionSet ¶
type DecisionSet struct { Decisions []*Decision // contains filtered or unexported fields }
func NewDecisionSet ¶
func NewDecisionSet(repoPath, idsFilePath string, opts ...DecisionSetOpt) (*DecisionSet, error)
func (*DecisionSet) DisplayDashboard ¶
func (ds *DecisionSet) DisplayDashboard() error
func (*DecisionSet) FilteredDecisions ¶
func (ds *DecisionSet) FilteredDecisions() []Decision
func (*DecisionSet) LoadDecision ¶
func (ds *DecisionSet) LoadDecision(decision Decision) Decision
Add a decision to DecisionSet, keeping in mind the DecisionSet's state This means this function adjusts the ID of the decision (only if necessary), adds a UUID if none exists, and adds the Created time if it isn't there either
func (*DecisionSet) MustUpdateDecision ¶
func (ds *DecisionSet) MustUpdateDecision(d Decision) error
replace decision in set with the new one
func (*DecisionSet) SavePendingChanges ¶
func (ds *DecisionSet) SavePendingChanges() error
save pending changes to disk
type DecisionSetOpt ¶
type DecisionSetOpt func(opts *DecisionSetOpts)
func WithIDs ¶
func WithIDs(ids ...int) DecisionSetOpt
func WithStatuses ¶
func WithStatuses(statuses ...string) DecisionSetOpt
func WithTags ¶
func WithTags(tags ...string) DecisionSetOpt
type DecisionSetOpts ¶
type DecisionSetOpts struct {
// contains filtered or unexported fields
}
type IdsMap ¶
persistent DB of UUID -> ID Ensures that decision have a persistent ID local to the machine for their lifetime Ensures the correct decision is targeted between operations