data

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2020 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package data contains all the data manipulation logic for punchcard

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckEntry

func CheckEntry(w *WorkLogEntry, projects ProjectMap) error

CheckEntry validates a WorkLogEntry

func WriteData

func WriteData(path string, pcd *PunchcardData) error

WriteData reads all the data from the data file

Types

type Project

type Project struct {
	Name        string
	Description string
	Reference   string `yaml:",omitempty"`
	Closed      bool   `yaml:",omitempty"`
}

Project is a container for WorkLogEntry objects. I.e. every WorkLogEntry belongs to a Project.

type ProjectMap

type ProjectMap map[string]Project

ProjectMap maps the Project.Name to the Project

type PunchcardData

type PunchcardData struct {
	Projects ProjectMap
	Entries  WorkLog
	Current  *WorkLogEntry `yaml:",omitempty"`
}

PunchcardData is the overall type for data stored

func ReadData

func ReadData(path string) (*PunchcardData, error)

ReadData reads all the data from the data file

func (*PunchcardData) AddEntry

func (pcd *PunchcardData) AddEntry(entry *WorkLogEntry) error

AddEntry adds a WorkLogEntry to the data

func (*PunchcardData) AddProject

func (pcd *PunchcardData) AddProject(p *Project) error

AddProject adds a Project to the data

func (*PunchcardData) FinishCurrent

func (pcd *PunchcardData) FinishCurrent(t time.Time) error

FinishCurrent finishes the Current and adds it to Entries

func (*PunchcardData) GetEntry added in v0.4.3

func (pcd *PunchcardData) GetEntry(index int) *WorkLogEntry

GetEntry returns the WorkLogEntry at index, or nil if index < 0 or index >= len(pcd.Entries)

func (*PunchcardData) GetLastEntry

func (pcd *PunchcardData) GetLastEntry() *WorkLogEntry

GetLastEntry returns the last WorkLogEntry in the list

func (*PunchcardData) GetLastEntryForProject

func (pcd *PunchcardData) GetLastEntryForProject(name string) *WorkLogEntry

GetLastEntryForProject returns the last WorkLogEntry in the list for project

func (*PunchcardData) RenameProject added in v0.3.0

func (pcd *PunchcardData) RenameProject(oldName string, newName string) error

RenameProject renames a Project and the entries

func (*PunchcardData) SetCurrent

func (pcd *PunchcardData) SetCurrent(entry *WorkLogEntry) error

SetCurrent adds a WorkLogEntry as the current

type WorkLog

type WorkLog []WorkLogEntry

WorkLog is a collection of WorkLogEntry items

type WorkLogEntry

type WorkLogEntry struct {
	Start     time.Time
	End       time.Time
	Project   string
	Message   string
	Reference string `yaml:",omitempty"`
}

WorkLogEntry holds the details of a single entry in the work log.

Jump to

Keyboard shortcuts

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