yata

package
v0.0.0-...-2b30a08 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2017 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LogVerbose = iota
	LogInfo
	LogWarning
	LogError
	LogNone
)
View Source
const (
	GoogleDrive = iota
	Dropbox
)
View Source
const (
	LowPriority    = 1
	NormalPriority = 2
	HighPriority   = 3
)
View Source
const (
	Simple = iota
	JSON
)

Variables

View Source
var LogLevel = LogInfo

LogLevel represents the lowest level of logging the user wants displayed during the execution of the app

View Source
var SynchronizableFiles = []struct {
	Name, Path string
}{
	{Name: "tasks.json", Path: GetDirectory().TasksFilePath()},
	{Name: "id", Path: GetDirectory().IDPath()},
}

SynchronizableFiles represents each file that will be synchronized

Functions

func HandleError

func HandleError(err error, exit bool)

HandleError will log a non-nil error and if exit is true, then it will exit with an exit code of 1

func HandleErrorWithFunc

func HandleErrorWithFunc(err error, exit bool, fun ErrorCheckFunc)

HandleErrorWithFunc will log a non-nil error if it also satisfies the provided function. If exit is true, it will exit with an exit code of 1

func NewTaskStringer

func NewTaskStringer(t Task, stringerType int8) fmt.Stringer

NewTaskStringer TODO docs

func Print

func Print(a ...interface{})

Print will display a string with the configured io.Writer

func PrintColor

func PrintColor(style string, a ...interface{})

PrintColor will display a string styled with mgutz/ansi styles with the configured io.Writer

func Printf

func Printf(format string, a ...interface{})

Printf will display a string with the configured io.Writer using the provided format

func PrintfColor

func PrintfColor(style, format string, a ...interface{})

PrintfColor will display a string styled with mgutz/ansi styles with the configured io.Writer using the provided format

func Println

func Println(a ...interface{})

Println will display a string with the configured io.Writer

func PrintlnColor

func PrintlnColor(style string, a ...interface{})

PrintlnColor will display a string styled with mgutz/ansi styles with the configured io.Writer

func ReadInt

func ReadInt() (n int)

ReadInt will read an integer from the configured io.Reader

func Readln

func Readln() (str string)

Readln will get input terminated with a newline from the configured io.Reader

Types

type Archiver

type Archiver struct{}

Archiver TODO docs

func NewArchiver

func NewArchiver() *Archiver

NewArchiver TODO docs

func (Archiver) Zip

func (a Archiver) Zip() error

Zip TODO docs

type ByDescription

type ByDescription []Task

ByDescription TODO docs

func (ByDescription) Len

func (t ByDescription) Len() int

func (ByDescription) Less

func (t ByDescription) Less(i, j int) bool

func (ByDescription) Swap

func (t ByDescription) Swap(i, j int)

type ByID

type ByID []Task

ByID TODO docs

func (ByID) Len

func (t ByID) Len() int

func (ByID) Less

func (t ByID) Less(i, j int) bool

func (ByID) Swap

func (t ByID) Swap(i, j int)

type ByPriority

type ByPriority []Task

ByPriority TODO docs

func (ByPriority) Len

func (t ByPriority) Len() int

func (ByPriority) Less

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

func (ByPriority) Swap

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

type ByTimestamp

type ByTimestamp []Task

ByTimestamp TODO docs

func (ByTimestamp) Len

func (t ByTimestamp) Len() int

func (ByTimestamp) Less

func (t ByTimestamp) Less(i, j int) bool

func (ByTimestamp) Swap

func (t ByTimestamp) Swap(i, j int)

type Config

type Config struct {
	GoogleDrive GoogleDriveJSON `json:"googleDrive"`
	Dropbox     DropboxJSON     `json:"dropbox"`
}

Config TODO docs

func DefaultConfig

func DefaultConfig() Config

DefaultConfig TODO docs

func (Config) Mapify

func (c Config) Mapify() map[string]interface{}

Mapify TODO docs

type ConfigManager

type ConfigManager struct {
	Config Config
}

ConfigManager TODO docs

func NewConfigManager

func NewConfigManager() *ConfigManager

NewConfigManager TODO docs

func (ConfigManager) GetAll

func (m ConfigManager) GetAll() (values map[string]string, err error)

GetAll TODO docs

func (ConfigManager) GetKeys

func (m ConfigManager) GetKeys() (keys []string, err error)

GetKeys TODO docs

func (ConfigManager) GetValueForKey

func (m ConfigManager) GetValueForKey(key string) (value string, err error)

GetValueForKey TODO docs

func (*ConfigManager) LoadConfig

func (m *ConfigManager) LoadConfig()

LoadConfig TODO docs

func (ConfigManager) SetKey

func (m ConfigManager) SetKey(key string, value interface{}) error

SetKey TODO docs

type Database

type Database interface {
	Read(collection string, v interface{}) error
	Write(collection string, v interface{}) error
}

Database TODO docs

func NewDatabase

func NewDatabase(dir string) Database

NewDatabase TODO docs

func NewJSONDatabase

func NewJSONDatabase(dir string) Database

NewJSONDatabase TODO docs

type Directory

type Directory struct {
	Root     string
	Filename string
}

Directory represents the Yata directory

func GetDirectory

func GetDirectory() *Directory

GetDirectory gets the Yata directory

func (Directory) Backup

func (d Directory) Backup()

Backup creates a new backup of the current tasks file

func (Directory) BackupPath

func (d Directory) BackupPath() string

BackupPath constructs the path to the next valid backup path

func (Directory) Config

func (d Directory) Config() ([]byte, error)

Config returns the entire config file as a byte slice

func (Directory) ConfigPath

func (d Directory) ConfigPath() string

ConfigPath constructs the path to the config file

func (Directory) CurrentID

func (d Directory) CurrentID() uint32

CurrentID returns the current ID in the Yata ID metadata file

func (Directory) EmptyFetchDir

func (d Directory) EmptyFetchDir()

EmptyFetchDir deletes any previously fetched files

func (Directory) FetchDir

func (d Directory) FetchDir() string

FetchDir constructs the path to the fetch directory

func (Directory) IDPath

func (d Directory) IDPath() string

IDPath constructs the path to the ID file

func (Directory) IncrementID

func (d Directory) IncrementID() uint32

IncrementID increments the current ID and returns the result

func (Directory) Initialize

func (d Directory) Initialize()

Initialize will recreate any part of the Yata directory that is missing

func (Directory) MetadataDir

func (d Directory) MetadataDir() string

MetadataDir constructs the path to the metadata directory

func (Directory) Reset

func (d Directory) Reset(resetID bool)

Reset deletes current tasks and if resetID is true, will also set the ID back to 0

func (Directory) TasksFilePath

func (d Directory) TasksFilePath() string

TasksFilePath constructs the path to the tasks file

func (Directory) WriteConfig

func (d Directory) WriteConfig(config []byte) error

WriteConfig writes the entire config file at once

func (Directory) WriteID

func (d Directory) WriteID(id uint32)

WriteID saves the provided ID to the ID file

type DriveAPI

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

DriveAPI wraps the Google Drive API within an implementation of the SyncAPI interface

func (DriveAPI) Fetch

func (m DriveAPI) Fetch()

Fetch downloads Yata application files from Google Drive to the specified fetch directory

func (DriveAPI) Push

func (m DriveAPI) Push()

Push uploads Yata files to Google Drive under the application data folder

type DropboxJSON

type DropboxJSON struct {
	APIKey string `json:"apiKey"`
}

DropboxJSON TODO docs

type ErrorCheckFunc

type ErrorCheckFunc func(error) bool

ErrorCheckFunc represents a function that will be used in addition to the nil error check

Example

func (err error) bool {
	return err != io.EOF
}

type FileLogger

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

FileLogger TODO docs

func (FileLogger) Error

func (l FileLogger) Error(msg string)

Error TODO docs

func (FileLogger) Info

func (l FileLogger) Info(msg string)

Info TODO docs

func (FileLogger) Verbose

func (l FileLogger) Verbose(msg string)

Verbose TODO docs

func (FileLogger) Warning

func (l FileLogger) Warning(msg string)

Warning TODO docs

func (FileLogger) Write

func (l FileLogger) Write(lvl int, msg string)

Write TODO docs

type GoogleDriveJSON

type GoogleDriveJSON struct {
	OAuthToken *oauth2.Token `json:"oauthToken"`
	SecretFile string        `json:"secretFile"`
}

GoogleDriveJSON TODO docs URL to generate secret file: https://developers.google.com/drive/v3/web/quickstart/go

type JSONDatabase

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

JSONDatabase TODO docs

func (JSONDatabase) Read

func (db JSONDatabase) Read(collection string, v interface{}) error

Read TODO docs

func (JSONDatabase) Write

func (db JSONDatabase) Write(collection string, v interface{}) error

type JSONStringer

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

JSONStringer TODO docs

func (JSONStringer) String

func (s JSONStringer) String() string

String TODO docs

type Logger

type Logger interface {
	Verbose(string)
	Info(string)
	Warning(string)
	Error(string)
	Write(int, string)
}

Logger provides the contract for logging verbose, info, warning, and error messages using a pre-defined heirarchy

func GetLogger

func GetLogger() Logger

GetLogger gets the configured logger or if a logger is not set, will create a new FileLogger

type NoneAPI

type NoneAPI struct{}

NoneAPI represents the lack of a configured synchronization service, so that the nil case does not need handled separately

func (NoneAPI) Fetch

func (m NoneAPI) Fetch()

Fetch will display a helpful message about configuring a synchronization service to the user

func (NoneAPI) Push

func (m NoneAPI) Push()

Push will display a helpful message about configuring a synchronization service to the user

type Predicate

type Predicate func(Task) bool

Predicate TODO docs

type SimpleStringer

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

SimpleStringer TODO docs

func (SimpleStringer) String

func (s SimpleStringer) String() string

String TODO docs

type SyncAPI

type SyncAPI interface {
	Push()
	Fetch()
}

SyncAPI provides the contract necessary for any service that synchronizes yata data

func NewSyncAPI

func NewSyncAPI(serverType int) SyncAPI

NewSyncAPI creates a new instance of a synchronization service

type Task

type Task struct {
	ID          uint32   `json:"id"`
	Description string   `json:"desc"`
	Completed   bool     `json:"done"`
	Priority    int      `json:"priority"`
	Tags        []string `json:"tags"`
	Timestamp   int64    `json:"timestamp"`
	UUID        string   `json:"uuid"`
}

Task TODO docs

func FilterTasks

func FilterTasks(tasks []Task, pred Predicate) []Task

FilterTasks TODO docs

func NewTask

func NewTask(description string, tags []string, priority int) *Task

NewTask TODO docs

func (*Task) ExtractTags

func (t *Task) ExtractTags()

ExtractTags TODO docs

func (*Task) MarshalTask

func (t *Task) MarshalTask() (dat []byte, err error)

MarshalTask TODO docs

func (*Task) String

func (t *Task) String() string

String TODO docs

type TaskManager

type TaskManager struct {
	Database   Database
	Collection string
}

TaskManager TODO docs

func NewTaskManager

func NewTaskManager() *TaskManager

NewTaskManager TODO docs

func (TaskManager) Backup

func (m TaskManager) Backup()

Backup TODO docs

func (TaskManager) DeleteByID

func (m TaskManager) DeleteByID(id uint32) error

DeleteByID TODO docs

func (TaskManager) GetAll

func (m TaskManager) GetAll() (tasks []Task, err error)

GetAll TODO docs

func (TaskManager) GetByID

func (m TaskManager) GetByID(id uint32) (*Task, error)

GetByID TODO docs

func (TaskManager) MergeFetchFiles

func (m TaskManager) MergeFetchFiles()

MergeFetchFiles TODO docs

func (TaskManager) Prune

func (m TaskManager) Prune() error

Prune TODO docs

func (TaskManager) Reset

func (m TaskManager) Reset(resetID bool)

Reset TODO docs

func (TaskManager) Save

func (m TaskManager) Save(t Task) error

Save TODO docs

Jump to

Keyboard shortcuts

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