cfg

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package cfg used for process configuration

Package cfg used for process configuration

Index

Constants

This section is empty.

Variables

View Source
var ModuleConfig = map[string]OptionsConfig{
	"watchlist": {
		SearchIDType: []string{},
		SearchType:   []string{},
		SearchField:  []string{},
		Type:         []string{"movies", "shows", "episodes", "persons"},
		Sort:         []string{"rank", "added", "released", "title"},
		Format:       []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"},
		Action:       []string{},
	},
	"collection": {
		SearchIDType: []string{},
		SearchType:   []string{},
		SearchField:  []string{},
		Type:         []string{"movies", "shows", "episodes", "persons"},
		Sort:         []string{"rank", "added", "released", "title"},
		Format:       []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"},
		Action:       []string{},
	},
	"comments": {
		SearchIDType: []string{},
		SearchType:   []string{},
		CommentType:  []string{"all", "review", "shouts"},
		SearchField:  []string{},
		Type:         []string{"all", "movies", "shows", "seasons", "episodes", "lists"},
		Sort:         []string{"rank", "added", "released", "title"},
		Format:       []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"},
		Action:       []string{},
	},

	"history": {
		SearchIDType: []string{},
		SearchType:   []string{},
		SearchField:  []string{},
		Type:         []string{"movies", "shows", "episodes", "persons"},
		Sort:         []string{"rank", "added", "released", "title"},
		Format:       []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"},
		Action:       []string{},
	},
	"lists": {
		SearchIDType: []string{},
		SearchType:   []string{},
		SearchField:  []string{},
		Type:         []string{"movies", "shows", "episodes", "persons"},
		Sort:         []string{"rank", "added", "released", "title"},
		Format:       []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"},
		Action:       []string{},
	},
	"people": {
		SearchIDType: []string{},
		SearchType:   []string{},
		SearchField:  []string{},
		Type:         []string{"movies", "shows", "episodes", "persons", "all", "personal", "official"},
		Sort:         []string{"rank", "added", "released", "title", "popular", "likes", "comments", "items", "added", "updated"},
		Format:       []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"},
		Action:       []string{},
	},
	"search": {
		SearchIDType: []string{"trakt", "imdb", "tmdb", "tvdb"},
		SearchType:   []string{"movie", "show", "episode", "person", "list", "podcast", "podcast_episode"},
		SearchField:  []string{"title", "aliases", "biography", "description", "episode", "name", "overview", "people", "show", "tagline", "translations"},
		Type:         []string{"movies", "shows", "episodes", "persons", "all", "personal", "official"},
		Sort:         []string{"rank", "added", "released", "title", "popular", "likes", "comments", "items", "added", "updated"},
		Format:       []string{"imdb", "tmdb", "tvdb", "tvrage", "trakt"},
		Action:       []string{},
	},
	"users": {
		SearchIDType: []string{},
		SearchType:   []string{},
		SearchField:  []string{},
		Type:         []string{"movies", "shows"},
		Sort:         []string{},
		Format:       []string{},
		Action:       []string{},
	},
}

ModuleConfig represents the configuration options for all modules

View Source
var SearchFieldConfig = map[string][]string{
	"movie":   {"title", "tagline", "overview", "people", "translations", "aliases"},
	"show":    {"title", "overview", "people", "translations", "aliases"},
	"episode": {"title", "overview"},
	"person":  {"name", "biography"},
	"list":    {"name", "description"},
}

SearchFieldConfig represents the configuration options for search_field depens on type

Functions

func GenUsedFlagMap

func GenUsedFlagMap() map[string]bool

GenUsedFlagMap map of used flags

func GetOptionTime

func GetOptionTime(options *str.Options) string

GetOptionTime config Time depends on Module name

func GetOutputForModule added in v1.0.3

func GetOutputForModule(options *str.Options) string

GetOutputForModule generates output value depends on module name

func IsValidConfigType

func IsValidConfigType(allowedTypes []string, userType string) bool

IsValidConfigType checks if the provided type is valid for the module

func IsValidConfigTypeSlice

func IsValidConfigTypeSlice(allowedElements []string, userElements str.Slice) bool

IsValidConfigTypeSlice checks if all elements of userElements are in allowedElements, considering the counts of each element.

func OptionsFromConfig

func OptionsFromConfig(fs afero.Fs, config *Config) (str.Options, error)

OptionsFromConfig reads options from config file

func SyncOptionsFromFlags

func SyncOptionsFromFlags(fs afero.Fs, config *Config, flagMap map[string]string) (str.Options, error)

SyncOptionsFromFlags reads options from user flags

func ValidateConfig

func ValidateConfig(module string, config OptionsConfig) bool

ValidateConfig validates if the provided configuration is allowed for the given module

Types

type Config

type Config struct {
	UserName       string    `toml:"username"`
	ConfigPath     string    `toml:"config_path"`
	Action         string    `toml:"action"`
	TokenPath      string    `toml:"token_path"`
	Type           string    `toml:"type"`
	Output         string    `toml:"output"`
	ID             string    `toml:"id"`
	SearchIDType   string    `toml:"search_id_type"`
	RedirectURI    string    `toml:"redirect_uri"`
	ClientSecret   string    `toml:"client_secret"`
	List           string    `toml:"list"`
	Format         string    `toml:"format"`
	ClientID       string    `toml:"client_id"`
	Query          string    `toml:"query"`
	Field          string    `toml:"field"`
	Sort           string    `toml:"sort"`
	CommentsSort   string    `toml:"sort"`
	Module         string    `toml:"module"`
	SearchField    str.Slice `toml:"search_field"`
	SearchType     str.Slice `toml:"search_type"`
	WarningCode    int       `toml:"warningCode"`
	ErrorCode      int       `toml:"errorCode"`
	Days           int       `toml:"days"`
	PerPage        int       `toml:"per_page"`
	PagesLimit     int       `toml:"pages_limit"`
	TraktID        int       `toml:"trakt_id"`
	CommentID      int       `toml:"comment_id"`
	EpisodeAbs     int       `toml:"episode_abs"`
	EpisodeCode    string    `toml:"episode_code"`
	Episode        int       `toml:"episode"`
	Season         int       `toml:"season"`
	Msg            string    `toml:"msg"`
	Comment        string    `toml:"comment"`
	CommentType    string    `toml:"comment_type"`
	Reply          string    `toml:"reply"`
	Remove         bool      `toml:"remove"`
	Delete         bool      `toml:"delete"`
	Spoiler        bool      `toml:"spoiler"`
	IncludeReplies string    `toml:"include_replies"`
	Verbose        bool      `toml:"verbose"`
}

Config struct for app.

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig config with default values

func GetConfig

func GetConfig(fs afero.Fs, configPath string) (*Config, error)

GetConfig yields the configuration

func InitConfig

func InitConfig(fs afero.Fs) (*Config, error)

InitConfig of app

func MergeConfigs

func MergeConfigs(defaultConfig *Config, fileConfig *Config, flagConfig map[string]string) (*Config, error)

MergeConfigs from two sources file and flags

func ReadConfigFromFile

func ReadConfigFromFile(fs afero.Fs, filename string) (*Config, error)

ReadConfigFromFile reads config from file stored on disc

type OptionsConfig

type OptionsConfig struct {
	SearchIDType []string
	CommentType  []string
	SearchType   []string
	SearchField  []string
	Type         []string
	Sort         []string
	Format       []string
	Action       []string
}

OptionsConfig represents the configuration options for each module

Jump to

Keyboard shortcuts

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