sync

package
v0.0.0-...-1a94de1 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sources

func Sources(changed []string, config Config, fs filesystem.Interface) ([]string, error)

Types

type CardResult

type CardResult struct {
	Created  int
	Updated  int
	Archived int
}

func SynchronizeCards

func SynchronizeCards(ctx context.Context, parsers []parser.Parser, sources []string, lock *Lock, config Config, client Client, fs filesystem.Interface, logger Logger) (CardResult, error)

type Client

type Client interface {
	ListCardsInDeck(ctx context.Context, id string) ([]api.Card, error)
	CreateCard(ctx context.Context, req api.CreateCardRequest) (api.Card, error)
	UpdateCard(ctx context.Context, id string, req api.UpdateCardRequest) (api.Card, error)
	ListDecks(ctx context.Context) ([]api.Deck, error)
	CreateDeck(ctx context.Context, req api.CreateDeckRequest) (api.Deck, error)
	UpdateDeck(ctx context.Context, id string, req api.UpdateDeckRequest) (api.Deck, error)
	ListTemplates(ctx context.Context) ([]api.Template, error)
}

type Config

type Config struct {
	Sync      []Sync              `yaml:"sync"`
	Ignore    []string            `yaml:"ignore"`
	Templates map[string]Template `yaml:"templates"`
	// contains filtered or unexported fields
}

func ReadConfig

func ReadConfig(ctx context.Context, parsers []parser.Parser, client Client, fs filesystem.Interface) (Config, error)

type DeckResult

type DeckResult struct {
	Created int
	Updated int
}

func SynchronizeDecks

func SynchronizeDecks(ctx context.Context, sources []string, lock *Lock, config Config, client Client, logger Logger) (DeckResult, error)

type Lock

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

func ReadLock

func ReadLock(ctx context.Context, client Client, fs filesystem.Interface) (*Lock, error)

func (*Lock) Write

func (l *Lock) Write(fs filesystem.Interface) (bool, error)

type Logger

type Logger interface {
	Error(message string)
	Errorf(format string, args ...any)
	Info(message string)
	Infof(format string, args ...any)
}

type Sync

type Sync struct {
	Path     string `yaml:"path"`
	Name     string `yaml:"name"`
	Parser   string `yaml:"parser"`
	Template string `yaml:"template"`
	Archive  bool   `yaml:"archive"`
	Walk     bool   `yaml:"walk"`
}

type Template

type Template struct {
	Parser     string            `yaml:"parser"`
	TemplateID string            `yaml:"templateId"`
	Fields     map[string]string `yaml:"fields"`
}

Jump to

Keyboard shortcuts

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