entities

package
v0.0.0-...-a08e0d8 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2017 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsWorking

func IsWorking(e *Env) (bool, error)

IsWorking validates if some task is working

Types

type ConfigFile

type ConfigFile struct {
	Project string `json:"project"`

	Exists bool   `json:"-"`
	Path   string `json:"-"`
}

ConfigFile defines the structure of the file used to configure a project

func GetConfig

func GetConfig() (*ConfigFile, error)

GetConfig returns the current configuration of the project you are in

func NewConfigFile

func NewConfigFile(project string) *ConfigFile

NewConfigFile creates a ConfigFile witht the provided name

func (*ConfigFile) Save

func (c *ConfigFile) Save() error

Save stores the ConfigFile to disk on the corresponding path

type Env

type Env struct {
	DataHome       string
	ConfigHome     string
	ProjectsPath   string
	RootConfigPath string
}

Env type holds all the data destinations for 'got'

func NewEnv

func NewEnv() (*Env, error)

NewEnv initialize the Env with all the data, with is read from the system ENV. It follows the https://specifications.freedesktop.org/basedir-spec/latest/ convention

func (*Env) Clean

func (e *Env) Clean()

Clean removes all the data that the program has generated including the .go.json on each project

func (*Env) SetUp

func (e *Env) SetUp() error

SetUp creates the needed directories if some is missing

type FilterOption

type FilterOption func(*ReportFilter)

func WithFilterFrom

func WithFilterFrom(f time.Time) FilterOption

func WithFilterProject

func WithFilterProject(p string) FilterOption

func WithFilterTo

func WithFilterTo(t time.Time) FilterOption

type Project

type Project struct {
	Name    string
	Seconds int
}

Project hold the data of one Project

func (*Project) Add

func (p *Project) Add(s int)

Add adds seconds to the internal seconds of the Project

func (*Project) Duration

func (p *Project) Duration() time.Duration

Duration returns the Seconds as a Duration

type Projects

type Projects map[string]string

Projects hold the information of all the known projects initialized. The structure is project_name => path_to_config_file

func GetProjects

func GetProjects(e *Env) (Projects, error)

GetProjects returns all the Projects from the projects.json file

func (Projects) Clean

func (p Projects) Clean(e *Env)

Clean removes all the Projects config files that it knows of

func (Projects) Save

func (p Projects) Save(e *Env) error

Save stores the Projects to the the projects.json file

type Report

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

Report holds all the projects aggregated

func NewReport

func NewReport(e *Env, rf *ReportFilter) (*Report, error)

NewReport initializes a new reporter and populates it

func (Report) Add

func (r Report) Add(t *Task)

Add adds a t.Seconds to the corresponding project or creates a new one

func (Report) String

func (r Report) String() string

String formats the output of the Reporter

type ReportFilter

type ReportFilter struct {
	From    time.Time
	To      time.Time
	Project string
}

func NewReportFilter

func NewReportFilter(filters ...FilterOption) (*ReportFilter, error)

type Task

type Task struct {
	Description string     `json:"description,omitempty"`
	Project     string     `json:"project"`
	Start       *time.Time `json:"start"`
	Stop        *time.Time `json:"stop,omitempty"`
	Seconds     int        `json:"seconds,omitempty"`
}

Task holds the information of a task that you have workder (or currently working)

func NewTask

func NewTask(project string) *Task

NewTask creates a Task for the project

func NewTaskFromCurrent

func NewTaskFromCurrent(e *Env) (*Task, error)

NewTaskFromCurrent loads the current task working on (on the 'current' file)

func NewTaskFromPath

func NewTaskFromPath(p string) (*Task, error)

NewTaskFromPath loads a task from a path

func (*Task) Duration

func (t *Task) Duration() time.Duration

Duration returns the Seconds as a Duration

func (*Task) PathToTask

func (t *Task) PathToTask(e *Env) string

PathToTask returns the path in which the Task is

func (*Task) Save

func (t *Task) Save(e *Env) error

Save stores the Task to disk to the corresponding location

func (*Task) StartWorking

func (t *Task) StartWorking(e *Env) error

StartWorking saves the Task and sets it to the 'current'

func (*Task) StopWorking

func (t *Task) StopWorking(e *Env) error

StopWorking sets the task as finished and removes the 'current'

func (*Task) String

func (t *Task) String() string

Jump to

Keyboard shortcuts

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