eda

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2023 License: MIT Imports: 7 Imported by: 0

README

EDA - Expenses data file format

A simple expenses log for families.

Quick start

$ go install github.com/gregoryv/eda/cmd/budget@latest

Create a file like the example.eda and run

$ budget example.eda

Read more about the file format on https://gregoryv.github.io/eda.

Documentation

Overview

Expenses data format

# Comments start with a '#' and empty lines are ignored

# Special comments
#
# expense   signals following lines are expenses (default)
# loan      signals following lines are loan entries
#
# expense
# amount/(y|m) tags
1000/m electricity
100/m mobile
40/m github
...

# loan
# left interest installment tags
686453     3.34        599  loan house
 68800     5.39        700  loan car
...

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry interface {
	// Monthly returns the monthly amount.
	Monthly() int
	Tags() []string
}

Entry represents data lines

func Parse

func Parse(r io.Reader) ([]Entry, error)

Parse returns entries until io.EOF is reached or an error occurs. When done nil error is returned.

Example
budget := `
# home
6000/year electricity
1000/m food

# clothes and stuff
500/m clothes linnen

# loan
100000  5.0 0 car

# expense
100/m internet
`
entries, err := Parse(strings.NewReader(budget))
if err != nil {
	log.Fatal(err)
}
for _, e := range entries {
	fmt.Println(e.Monthly(), e.Tags())
}
Output:
6000 [electricity]
1000 [food]
500 [clothes linnen]
416 [car]
100 [internet]

type Expense

type Expense struct {
	Amount int
	Period string
	// contains filtered or unexported fields
}

Expense represents expense lines

func (*Expense) Monthly

func (e *Expense) Monthly() int

func (*Expense) Tags

func (e *Expense) Tags() []string

type Loan

type Loan struct {
	Left        int
	Interest    float64
	Installment int
	// contains filtered or unexported fields
}

Loan represents loan lines

func (*Loan) Monthly

func (l *Loan) Monthly() int

func (*Loan) Tags

func (l *Loan) Tags() []string

type Scanner

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

func NewScanner

func NewScanner(r io.Reader) *Scanner

func (*Scanner) Scan

func (s *Scanner) Scan() (Entry, error)

Scan returns next entry. Returns io.EOF when done or non nil error on failure to convert line to an Entry.

Directories

Path Synopsis
cmd
budget command
Command budget parses EDA files and prints out a summary
Command budget parses EDA files and prints out a summary
Command docs generates the gregoryv.github.io/eda pages
Command docs generates the gregoryv.github.io/eda pages

Jump to

Keyboard shortcuts

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