core

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2019 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WaitingStatus = "waiting"
	DoneStatus    = "done"
	SkippedStatus = "skipped"
	BumpedStatus  = "bumped"
)
View Source
const (
	HumanPrintFormat PrintFormat = 0
	TextPrintFormat  PrintFormat = 1
	JSONPrintFormat  PrintFormat = 2

	ColMinWidth    int = 2  // minimum column width
	ColSpacesLen   int = 3  // how many spaces between columns (inc newline col)
	LargestDateLen int = 12 // length of "- Wed Sep 23"
)
View Source
const DefaultTrimAtLength = 120
View Source
const (
	MaxIDLength = 6
)

Variables

This section is empty.

Functions

func Add

func Add(ctx context.Context, description io.Reader, timeString string) error

func AddDone

func AddDone(ctx context.Context, description io.Reader, timeString string) error

func Base36

func Base36(in int) rune

numbers above 35 translate to the value of remainder. i.e. 36 is 0, 71 is z, 72 is 0...

func Bump

func Bump(ctx context.Context, id string, timeString string) error

func CreateGroup

func CreateGroup(ctx context.Context, name string, filterString string) error

func DateFilterFn

func DateFilterFn(comparison filter.FilterComparison, val string) (filter.Filter, error)

func DefaultParser

func DefaultParser(store Store) *parser.Parser

func DeleteGroup

func DeleteGroup(ctx context.Context, name string) error

func Do

func Do(ctx context.Context, id string) error

func Edit

func Edit(ctx context.Context, idString string, description io.Reader, timeString string) error

edit description and time, not status

func EditDataFromFile

func EditDataFromFile(ctx context.Context, editID string) error

func GenerateID

func GenerateID(at time.Time) string

GenerateID generates a 6 digit ID - with the last three digits sortable by Year, Month, Day Format: RRRYMD - where R is a random base36 rune. This means, that in any given day, there's 36^3 chance of a random collision - acceptable for this.

func GroupFilterFn

func GroupFilterFn(store Store) parser.ToFilterFn

func IDSuffixForDate

func IDSuffixForDate(t time.Time) string

func Import

func Import(ctx context.Context, filename string) error

func List

func List(ctx context.Context, argString string, groupString string) error

func ListGroup

func ListGroup(ctx context.Context) error

func ListTag

func ListTag(ctx context.Context) error

func ReadToStore

func ReadToStore(ctx context.Context, f io.Reader) error

func Rm

func Rm(ctx context.Context, idString string) error

func Show

func Show(ctx context.Context, idString string) error

func Skip

func Skip(ctx context.Context, id string) error

func StatusFilterFn

func StatusFilterFn(comparison filter.FilterComparison, val string) (filter.Filter, error)

func TagFilterFn

func TagFilterFn(store Store) parser.ToFilterFn

func TrimString

func TrimString(input string, extraCharacterLength int) string

Types

type BoltStore

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

func NewBoltStore

func NewBoltStore(path string) (*BoltStore, error)

func (*BoltStore) Delete

func (s *BoltStore) Delete(item *Item) error

func (*BoltStore) DeleteGroup

func (s *BoltStore) DeleteGroup(group *Group) error

func (*BoltStore) DropBucket

func (s *BoltStore) DropBucket(bucket string)

func (*BoltStore) Find

func (s *BoltStore) Find(id string) (*Item, error)

func (*BoltStore) FindAll

func (s *BoltStore) FindAll(id string) ([]*Item, error)

func (*BoltStore) FindGroupByName

func (s *BoltStore) FindGroupByName(name string) (*Group, error)

func (*BoltStore) FindTag

func (s *BoltStore) FindTag(name string) (*Tag, error)

func (*BoltStore) ListFilters

func (s *BoltStore) ListFilters(filters []filter.Filter) ([]*Item, error)

func (*BoltStore) ListGroups

func (s *BoltStore) ListGroups() ([]*Group, error)

func (*BoltStore) ListTags

func (s *BoltStore) ListTags() ([]*Tag, error)

func (*BoltStore) Save

func (s *BoltStore) Save(item *Item) error

func (*BoltStore) SaveGroup

func (s *BoltStore) SaveGroup(group *Group) error

func (*BoltStore) SaveTag

func (s *BoltStore) SaveTag(tag *Tag) error

func (*BoltStore) WithContext

func (s *BoltStore) WithContext(ctx context.Context) Store

type DateFilter

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

func NewDateFilter

func NewDateFilter(comparison filter.FilterComparison, timespan *Timespan) *DateFilter

func (*DateFilter) Match

func (dateFilter *DateFilter) Match(i interface{}) (bool, error)

func (*DateFilter) String

func (dateFilter *DateFilter) String() string

type Group

type Group struct {
	Name         string
	FilterString string
	CreatedAt    time.Time
	// contains filtered or unexported fields
}

func NewGroup

func NewGroup(name string, filterString string) *Group

func (*Group) Filters

func (g *Group) Filters(store Store) ([]filter.Filter, error)

func (*Group) String

func (g *Group) String() string

type GroupFilter

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

func NewGroupFilter

func NewGroupFilter(comparison filter.FilterComparison, name string, filters []filter.Filter) *GroupFilter

func (*GroupFilter) Match

func (groupFilter *GroupFilter) Match(i interface{}) (bool, error)

func (*GroupFilter) String

func (groupFilter *GroupFilter) String() string

type GroupStore

type GroupStore interface {
	SaveGroup(group *Group) error
	DeleteGroup(group *Group) error
	ListGroups() ([]*Group, error)
	FindGroupByName(name string) (*Group, error)
}

type Item

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

func FindAll

func FindAll(ctx context.Context, idString string) ([]*Item, error)

func NewItem

func NewItem(data string, at time.Time) *Item

func (*Item) Bump

func (i *Item) Bump(newTime time.Time) *Item

func (*Item) Data

func (i *Item) Data() string

func (*Item) Do

func (i *Item) Do()

func (*Item) ID

func (i *Item) ID() string

func (*Item) NextID

func (i *Item) NextID() string

func (*Item) PreviousID

func (i *Item) PreviousID() string

func (*Item) ResetInternalID

func (i *Item) ResetInternalID()

func (*Item) SetID

func (i *Item) SetID(id string)

manually set the ID, useful for testing!

func (*Item) Skip

func (i *Item) Skip()

func (*Item) Status

func (i *Item) Status() string

func (*Item) String

func (i *Item) String() string

func (*Item) Tags

func (i *Item) Tags() []*Tag

func (*Item) Time

func (i *Item) Time() time.Time

type ItemCreator

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

func (*ItemCreator) Create

func (ic *ItemCreator) Create(data string, at time.Time) (*Item, error)

func (*ItemCreator) Delete

func (ic *ItemCreator) Delete(item *Item) error

func (*ItemCreator) Edit

func (ic *ItemCreator) Edit(item *Item, data string, timeString string) (*Item, error)

func (*ItemCreator) GenerateAndSaveMetadata

func (ic *ItemCreator) GenerateAndSaveMetadata(item *Item) error

type ItemPrinter

type ItemPrinter struct {
	PrintFormat PrintFormat
	// contains filtered or unexported fields
}

func NewItemPrinter

func NewItemPrinter(ctx context.Context) *ItemPrinter

func (*ItemPrinter) FPrint

func (ip *ItemPrinter) FPrint(w io.Writer, items ...*Item)

func (*ItemPrinter) Print

func (ip *ItemPrinter) Print(items ...*Item)

type ItemStore

type ItemStore interface {
	Find(id string) (*Item, error)
	FindAll(id string) ([]*Item, error)
	Delete(item *Item) error
	Save(item *Item) error
	ListFilters(filters []filter.Filter) ([]*Item, error)
}

type JSONItem

type JSONItem struct {
	ID         string
	InternalID string
	NextID     string
	PreviousID string

	Data       string
	Status     string
	TimeString string
	Tags       []string
}

type PrintFormat

type PrintFormat int

func GetPrintFormat

func GetPrintFormat(format string) PrintFormat

func GetPrintFormatFromContext

func GetPrintFormatFromContext(ctx context.Context) PrintFormat

type StatusFilter

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

func NewStatusFilter

func NewStatusFilter(comparison filter.FilterComparison, statuses ...string) *StatusFilter

func (*StatusFilter) Match

func (statusFilter *StatusFilter) Match(i interface{}) (bool, error)

func (*StatusFilter) String

func (statusFilter *StatusFilter) String() string

type Store

type Store interface {
	ItemStore
	TagStore
	GroupStore

	WithContext(ctx context.Context) Store
}

type StormGroup

type StormGroup struct {
	RowID        uint64 `storm:"id,increment"`
	Name         string `storm:"index,unique"`
	FilterString string
	CreatedAt    int64 `storm:"index"` // timestamp
}

type StormItem

type StormItem struct {
	RowID      uint64 `storm:"id,increment"`
	ID         string `storm:"index,unique"`
	NextID     string
	PreviousID string
	Data       string
	Status     string
	Datetime   int64 `storm:"index"`
}

type StormTag

type StormTag struct {
	RowID     uint64 `storm:"id,increment"`
	Name      string `storm:"index,unique"`
	CreatedAt int64  // timestamp
	Type      string `storm:"index"`
}

type Tag

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

func NewTag

func NewTag(name string) *Tag

func (*Tag) CreatedAt

func (t *Tag) CreatedAt() time.Time

func (*Tag) Name

func (t *Tag) Name() string

func (*Tag) String

func (t *Tag) String() string

func (*Tag) TagType

func (t *Tag) TagType() string

type TagFilter

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

func NewTagFilter

func NewTagFilter(store Store, comparison filter.FilterComparison, name string) *TagFilter

func (*TagFilter) Match

func (tagFilter *TagFilter) Match(i interface{}) (bool, error)

func (*TagFilter) String

func (tagFilter *TagFilter) String() string

type TagStore

type TagStore interface {
	FindTag(name string) (*Tag, error)
	SaveTag(tag *Tag) error
	ListTags() ([]*Tag, error)
}

type TimeParser

type TimeParser struct {
	Input string
	// contains filtered or unexported fields
}

func (TimeParser) Parse

func (tp TimeParser) Parse() (*Timespan, error)

type Timespan

type Timespan struct {
	Start time.Time
	End   time.Time
}

func NewTimespan

func NewTimespan(start, end time.Time) *Timespan

func (Timespan) EarliestTime

func (ts Timespan) EarliestTime() time.Time

func (Timespan) LatestTime

func (ts Timespan) LatestTime() time.Time

func (*Timespan) String

func (ts *Timespan) String() string

Jump to

Keyboard shortcuts

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