backend

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FormatFC indicates that user requested FC report format output
	FormatFC = iota
	// FormatJSON indicates that user requested JSON report format output
	FormatJSON = iota
	// FormatText indicates that user requested text template report format output
	FormatText
)
View Source
const DefaultEditor = "nano"

Defaults on Linux, MacOS

View Source
const DefaultTerm = "xterm"

Variables

View Source
var TemplateString = `` /* 516-byte string literal not displayed */

TemplateString defines the template used to output a Report() with FormatText

Functions

This section is empty.

Types

type Backend

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

Backend represents the context and configuration of every instance of the omw command Immediate commands (like omw add, omw report), immediately affect the timesheet Long-running commands (like omw server), maintain a context

func Create

func Create(fp *os.File, omwDir, omwFile string) *Backend

Create an instance of the structures that operate on Omw data

func (*Backend) Add

func (b *Backend) Add(args []string) error

Add appends the current time and task to your timesheet

func (*Backend) Close

func (b *Backend) Close() error

Close cleans up before exiting

func (*Backend) Edit

func (b *Backend) Edit() (bool, error)

Edit opens your current timesheet in your default editor or in the editor specified by the EDITOR environment variable Similar to visudo, will do some basic checks to ensure that any edits will still pass toml.Marshal() and that there are no duplicate IDs should return true, err to ask the caller to re-run Edit()

func (*Backend) Hello

func (b *Backend) Hello() error

Hello appends a newline and then another line to end of timesheet with current time and the word "Hello". Meant to be run at the beginning of a new work day

func (*Backend) Report

func (b *Backend) Report(start, end string, format string) (output string, err error)

Report outputs various report formats to one of the following types: Text - command-line default JSON - web default FC - web fullcalendar JSON feed URL Add 24 hours to the parsed end time so that when a user specifies --from 2019-01-01 --to 2019-01-02 that translates to "report on tasks that occurred between 2019-01-01 00:00 and "2019-01-03 00:00"

func (*Backend) Stretch

func (b *Backend) Stretch() error

Stretch append current timestamp to end of timesheet and copy previous task fp is opened in append mode, so seek to beginning of file first

type FCReport

type FCReport struct {
	Events []ReportEntry `json:"events"`
}

FCReport describes the format of a FullCalendar-compatible report

type Report

type Report struct {
	From      time.Time     `json:"reportFrom"`
	To        time.Time     `json:"reportTo"`
	IgnoreHrs time.Duration `json:"ignoreTotalHours"`
	BrkHrs    time.Duration `json:"breakTotalHours"`
	TaskHrs   time.Duration `json:"taskTotalHours"`
	Entries   []ReportEntry `json:"entries"`
	// contains filtered or unexported fields
}

Report describes a report previous is only used during report calculation to populate ReportEntry.Duration

type ReportEntry

type ReportEntry struct {
	ID         string        `json:"id,omitempty"`
	Brk        bool          `json:"break,omitempty"`
	ClassNames []string      `json:"classNames,omitempty"`
	Duration   time.Duration `json:"duration,omitempty"`
	Ignore     bool          `json:"ignore,omitempty"`
	Start      time.Time     `json:"start,omitempty"`
	End        time.Time     `json:"end,omitempty"`
	Title      string        `json:"title,omitempty"`
	Ts         time.Time     `json:"timestamp,omitempty"`
	URL        string        `json:"url,omitempty"`
}

ReportEntry describes a single entry in the timesheet Omw report and the REST API calculate some of the missing from the data stored on disk.

type SavedEntry

type SavedEntry struct {
	ID   string    `toml:"id"`
	End  time.Time `toml:"end"`
	Task string    `toml:"task"`
}

SavedEntry describes the TOML format saved on disk for each entry. Note that the stored data is minimized to make it more suitable for human consumption

type SavedItems

type SavedItems struct {
	Entries []SavedEntry `toml:"entries"`
}

SavedItems describes the structure of the entire TOML file.

Jump to

Keyboard shortcuts

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