configs

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

TODO: Verificar se root_config.go é necessário

Index

Constants

View Source
const (
	GSDEV_CONFIGURATION_ENV   = "GSDEV_CONFIGURATION"
	NO_ERROR                  = 0
	ERROR_MISSING_CONF_PATH   = 1
	ERROR_CONF_PATH_NOT_FOUND = 2
	ERROR_CONF_FILE_NOT_FOUND = 3
	ERROR_CONF_FILE_READ      = 4
	ERROR_CONF_FILE_INVALID   = 5
	ERROR_CONF_PATH_IO        = 6
)

Variables

View Source
var ConfigurationPath string
View Source
var DefaultConfigurationPath string

Functions

func Confirm

func Confirm(message string, defaultValue bool) bool

func Prompt

func Prompt(message string, defaultValue string) (value string, err error)

func PromptPath

func PromptPath(message string, defaultPath string) (value string, err error)

func SetupConfigurationRoot

func SetupConfigurationRoot(rootCommand *cobra.Command)

Types

type ConfigError added in v0.0.4

type ConfigError struct {
	ErrorCode int   `yaml:"-"`
	Error     error `yaml:"-"`
}

func (*ConfigError) SetErrorf added in v0.0.4

func (cfg *ConfigError) SetErrorf(errorCode int, format string, a ...interface{})

type ConfigFolder added in v0.0.4

type ConfigFolder struct {
	ConfigError `yaml:"-"`
	DataFolder  string `yaml:"-"`
}

func NewConfigFolder added in v0.0.4

func NewConfigFolder(cmd *cobra.Command) (cfg *ConfigFolder)

func (*ConfigFolder) LoadFile added in v0.0.4

func (cfg *ConfigFolder) LoadFile(fileName string) (content []byte, err error)

func (*ConfigFolder) SaveFile added in v0.0.4

func (cfg *ConfigFolder) SaveFile(fileName string, data any) error

type RootConfig

type RootConfig struct {
	DataFolder string `yaml:"-"`
	ConfigFile string `yaml:"-"`
	ErrorCode  int    `yaml:"-"`
	Error      string `yaml:"-"`
}

func ValidateConfiguration

func ValidateConfiguration(cmd *cobra.Command) (cfg RootConfig)

func (*RootConfig) Prompt

func (cfg *RootConfig) Prompt() bool

func (*RootConfig) ReadFile

func (cfg *RootConfig) ReadFile(filename string) error

func (*RootConfig) SetErrorf

func (cfg *RootConfig) SetErrorf(errorCode int, format string, a ...interface{})

func (*RootConfig) WriteFile

func (cfg *RootConfig) WriteFile(filename string) error

Jump to

Keyboard shortcuts

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