common

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//nolint:gosec // this is not a secret
	AuthAccessToken = "auth.access_token"
	//nolint:gosec // this is not a secret
	AuthExpiredAt = "auth.expired_at"
	//nolint:gosec // this is not a secret
	AuthRefreshToken = "auth.refresh_token"
	AuthUserID       = "auth.user_id"
)

Variables

View Source
var (
	ErrNotFound = Error{404, "Not found"}
)

Functions

func CleanDatabase

func CleanDatabase(db ToodledoConfigDatabase) error

func DefaultBuckets

func DefaultBuckets() []string

func InitViper

func InitViper(cfgFile string, cfgDirInHome string, cfgName string)

InitViper init viper with cfgFile or cfgDirInHome it must be called before viper.GetXXX, usually it was called in init().

Types

type ColorConfig

type ColorConfig struct {
	Foreground lipgloss.AdaptiveColor
	Background lipgloss.AdaptiveColor
}

type Error

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

Error is a type of error used for meta.

func (Error) Error

func (e Error) Error() string

Error returns the message in MetaError.

type ToodledoCliConfig

type ToodledoCliConfig struct {
	Endpoint       string                                `mapstructure:"endpoint" yaml:"host"`
	Auth           ToodledoConfig                        `mapstructure:"auth" yaml:"auth"`
	Database       ToodledoConfigDatabase                `mapstructure:"database omitempty"  yaml:"database omitempty"`
	Environment    map[string]*ToodledoConfigEnvironment `mapstructure:"environments  omitempty" yaml:"environment omitempty"`
	DefaultContext string                                `mapstructure:"default-environment" yaml:"defaultContext omitempty"`
	AutoRefresh    string                                `mapstructure:"auto-refresh" yaml:"autoRefresh omitempty"`
}

ToodledoCliConfig is configuration for toodledo cli and tui.

func NewCliConfigForTesting

func NewCliConfigForTesting() (ToodledoCliConfig, error)

func NewCliConfigFromViper

func NewCliConfigFromViper() (ToodledoCliConfig, error)

NewCliConfigFromViper build Configs from viper.

func NewCliConfigMockForTesting

func NewCliConfigMockForTesting() (ToodledoCliConfig, error)

func NewToodledoCliConfig

func NewToodledoCliConfig() ToodledoCliConfig

type ToodledoConfig

type ToodledoConfig struct {
	UserID       string `mapstructure:"user_id"`
	ClientID     string `mapstructure:"client_id" yaml:"client_id"`
	ClientSecret string `mapstructure:"client_secret" yaml:"client_secret"`
	AccessToken  string `mapstructure:"access_token" yaml:"access_token"`
	ExpiredAt    string `mapstructure:"expired_at" yaml:"expired_at"`
	RefreshToken string `mapstructure:"refresh_token" yaml:"refresh_token"`
}

ToodledoConfig is configuration for toodledo mapstructure docs in https://github.com/spf13/viper/issues/258#issuecomment-253730493

func NewConfigFromCliConfig

func NewConfigFromCliConfig(cfg ToodledoCliConfig) (ToodledoConfig, error)

type ToodledoConfigDatabase

type ToodledoConfigDatabase struct {
	DataFile string   `mapstructure:"data_file omitempty" yaml:"data_file omitempty"`
	Buckets  []string `mapstructure:"-" yaml:"-"`
}

func NewDefaultToodledoConfigDatabase

func NewDefaultToodledoConfigDatabase() ToodledoConfigDatabase

func NewToodledoConfigDatabaseFromToodledoCliConfig

func NewToodledoConfigDatabaseFromToodledoCliConfig(config ToodledoCliConfig) ToodledoConfigDatabase

type ToodledoConfigEnvironment

type ToodledoConfigEnvironment struct {
	Name    string `mapstructure:"name"`
	Folder  string `mapstructure:"folder"`
	Context string `mapstructure:"context"`
	Goal    string `mapstructure:"goal"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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