vdir

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: Unlicense Imports: 19 Imported by: 0

Documentation

Overview

The vdir package implements a simple library to interact with vdir filesystem storage: https://vdirsyncer.pimutils.org/en/stable/vdir.html

Index

Constants

View Source
const (
	MetaDisplayName = "displayname" // MetaDisplayName is a filename vdir uses for collection name
	MetaColor       = "color"       // MetaColor is a filename vdir uses for collection color
)
View Source
const (
	StatusCompleted   ToDoStatus = "COMPLETED"
	StatusNeedsAction ToDoStatus = "NEEDS-ACTION"
	StatusCancelled   ToDoStatus = "CANCELLED"
	StatusInProcess   ToDoStatus = "IN-PROCESS"
	StatusAny         ToDoStatus = "ANY"

	PriorityHigh   ToDoPriority = 1
	PriorityMedium ToDoPriority = 5
	PriorityLow    ToDoPriority = 6
)

Variables

This section is empty.

Functions

func GenerateUID

func GenerateUID() string

GenerateUID returns a random string containing timestamp and hostname

Types

type ByCreated

type ByCreated []*Item

func (ByCreated) Len

func (s ByCreated) Len() int

func (ByCreated) Less

func (s ByCreated) Less(i, j int) bool

func (ByCreated) Swap

func (s ByCreated) Swap(i, j int)

type ByDue

type ByDue []*Item

func (ByDue) Items added in v0.3.0

func (f ByDue) Items() []*Item

func (ByDue) Keep added in v0.3.0

func (f ByDue) Keep(item Item, i interface{}) (bool, error)

func (ByDue) Len

func (s ByDue) Len() int

func (ByDue) Less

func (s ByDue) Less(i, j int) bool

func (ByDue) Swap

func (s ByDue) Swap(i, j int)

type ByPriority

type ByPriority []*Item

func (ByPriority) Len

func (s ByPriority) Len() int

func (ByPriority) Less

func (s ByPriority) Less(i, j int) bool

func (ByPriority) Swap

func (s ByPriority) Swap(i, j int)

type ByStatus

type ByStatus []*Item

func (ByStatus) Items added in v0.3.0

func (f ByStatus) Items() []*Item

func (ByStatus) Keep added in v0.3.0

func (f ByStatus) Keep(item Item, i interface{}) (bool, error)

func (ByStatus) Len

func (s ByStatus) Len() int

func (ByStatus) Less

func (s ByStatus) Less(i, j int) bool

func (ByStatus) Swap

func (s ByStatus) Swap(i, j int)

type ByTags added in v0.3.0

type ByTags []*Item

func (ByTags) Items added in v0.3.0

func (f ByTags) Items() []*Item

func (ByTags) Keep added in v0.3.0

func (f ByTags) Keep(item Item, i interface{}) (bool, error)

type ByTagsExcluded added in v0.3.0

type ByTagsExcluded []*Item

func (ByTagsExcluded) Items added in v0.3.0

func (f ByTagsExcluded) Items() []*Item

func (ByTagsExcluded) Keep added in v0.3.0

func (f ByTagsExcluded) Keep(item Item, i interface{}) (bool, error)

type ByText added in v0.3.0

type ByText []*Item

func (ByText) Items added in v0.3.0

func (f ByText) Items() []*Item

func (ByText) Keep added in v0.3.0

func (f ByText) Keep(item Item, i interface{}) (bool, error)

type Collection

type Collection struct {
	Name  string
	Color string
	Path  string
}

Collection is a Vdir collection

func (*Collection) Init

func (c *Collection) Init(path string) error

Init initializes a Collection with a path, name and color parsed from path

func (*Collection) String

func (c *Collection) String() string

type DecodeError

type DecodeError struct {
	Path string
	Err  error
}

DecodeError is an error occured during ical decoding

func (*DecodeError) Error

func (d *DecodeError) Error() string

type FormatFullOption

type FormatFullOption int
const (
	FormatFullRaw FormatFullOption = iota
)

type FormatOption

type FormatOption int
const (
	FormatMultiline FormatOption = iota
	FormatDescription
)

type Item

type Item struct {
	Id   int
	Path string
	Ical *ical.Calendar
}

Item is an iCalendar item with a unique id

func Filter added in v0.3.0

func Filter(f filter, i interface{}) (filtered []*Item, err error)

func (*Item) Format

func (i *Item) Format(options ...FormatOption) (string, error)

Format returns a readable representation of an item

func (*Item) FormatFull

func (i *Item) FormatFull(options ...FormatFullOption) (string, error)

FormatFull returns a full detailed info about an item

func (*Item) HasTag added in v0.3.0

func (i *Item) HasTag(t Tag) (bool, error)

HasTag reports whether an item has a given tag

func (*Item) Init

func (i *Item) Init(path string) error

Init initializes an Item with a decoded ical data from path

func (*Item) Tags

func (i *Item) Tags() (tags []Tag, err error)

Tags returns a slice of hashtag strings parsed from summary and description

func (*Item) Vtodo

func (i *Item) Vtodo() (*ical.Component, error)

Vtodo returns a pointer to inner todo ical component

func (*Item) WriteFile

func (i *Item) WriteFile() error

WriteFile encodes ical data and writes to file at Item.Path

type Tag

type Tag string

Tag is a hashtag label in todo summary

func (Tag) String

func (t Tag) String() string

String returns a lowercased tag string without hash prefix

type ToDoPriority

type ToDoPriority int

type ToDoStatus

type ToDoStatus string

func (ToDoStatus) String added in v0.3.0

func (s ToDoStatus) String() string

String returns a lowercased todo status string

type Vdir

type Vdir map[*Collection][]*Item

Vdir is a map of all collections and items

func (*Vdir) Init

func (v *Vdir) Init(path string) error

Init initializes the map with collections and items in path, items have unique IDs

func (*Vdir) ItemById

func (v *Vdir) ItemById(id int) (*Item, error)

ItemById finds and returns an item for specified id

func (*Vdir) ItemByPath

func (v *Vdir) ItemByPath(path string) (*Item, error)

ItemByPath finds and returns an item for specified path

func (*Vdir) Tags

func (v *Vdir) Tags() (tags []Tag, err error)

Tags returns a slice of all tags found in todos inside vdir

Jump to

Keyboard shortcuts

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