config

package
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConfigDir      = ".tcli"
	DataDir        = "data"
	EnvConfigRoot  = "TCLI_CONFIG_ROOT"
	EnvConfigFile  = "TCLI_CONFIG_FILE"
	ConfigFileName = "config.yaml"
	ModuleFileName = "modules.yaml"
)
View Source
const (
	TokenFile = ".token"
)

Variables

View Source
var (
	DefaultHomeDir    = getHomeDir()
	DefaultConfigRoot = filepath.Join(DefaultHomeDir, ConfigDir)
	DefaultConfigFile = filepath.Join(getConfigRoot(), ConfigFileName)
)
View Source
var (
	// cache file path
	TokenCacheFile = fmt.Sprintf("%s/%s", getConfigDir(), TokenFile)
)

Functions

func CloseBodyReader

func CloseBodyReader(rc io.ReadCloser)

close w error check

func Load

func Load() bool

load config

func LoadModules

func LoadModules(configFile string) bool

func SetDocType

func SetDocType(doc string)

set doc

func SetVerboseLogging

func SetVerboseLogging()

set log level to verbose

func ShowCommand

func ShowCommand(module, cmd, subCmd string) (*parser.Method, error)

func ShowCommands

func ShowCommands(module string) error

show supported commands in the specified module

func ShowModuleCommands

func ShowModuleCommands(m *Module)

func ShowModules

func ShowModules()

func ShowTaggedCommands

func ShowTaggedCommands(cmd string)

Types

type Config

type Config struct {
	ProfileName    string    `yaml:"default_profile"`
	Profiles       []Profile `yaml:"profiles"`
	ModuleConfig   string    `yaml:"module_config"`
	CurrentProfile *Profile
	Modules        []Module
	TokenCache     *TokenCache
}

Config holds all profiles and overrides to current profile

func GetSettings

func GetSettings() *Config

return settings loaded from config

type DocProvider

type DocProvider interface {
	// initialize, set a handler
	Init() error
	// provide docs for http request
	HttpRequest(*http.Request)
	// provide docs for http response
	HttpResponse(*http.Response, []byte)
}

define interface for document generation

func NewDocProvider

func NewDocProvider(dt string) DocProvider

type DocProviderNone

type DocProviderNone struct {
}

func (*DocProviderNone) HttpRequest

func (d *DocProviderNone) HttpRequest(req *http.Request)

func (*DocProviderNone) HttpResponse

func (d *DocProviderNone) HttpResponse(resp *http.Response, body []byte)

func (*DocProviderNone) Init

func (d *DocProviderNone) Init() error

type DocProviderShell

type DocProviderShell struct {
}

func (*DocProviderShell) HttpRequest

func (d *DocProviderShell) HttpRequest(req *http.Request)

print curl request

func (*DocProviderShell) HttpResponse

func (d *DocProviderShell) HttpResponse(resp *http.Response, body []byte)

func (*DocProviderShell) Init

func (d *DocProviderShell) Init() error

type DocType

type DocType string

doctype declaration

const (
	None  DocType = ""
	Shell DocType = "shell"
)

type Level

type Level uint32

level declaration

const (
	Info Level = iota
	Verbose
)

type Log

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

func GetLogger

func GetLogger() *Log

provide a log util

func InitLogger

func InitLogger(l Level) *Log

func (*Log) Debug

func (l *Log) Debug(v ...any)

func (*Log) Debugf

func (l *Log) Debugf(format string, v ...any)

func (*Log) Error

func (l *Log) Error(v ...any)

this function is here for a possible decoration for errors right now, its the same as Println

func (*Log) Errorf

func (l *Log) Errorf(format string, v ...any)

func (*Log) Fatal

func (l *Log) Fatal(v ...any)

func (*Log) FatalIf

func (l *Log) FatalIf(err error)

func (*Log) Fatalf

func (l *Log) Fatalf(format string, v ...any)

func (*Log) GetPlainLogger

func (l *Log) GetPlainLogger() *log.Logger

func (*Log) HttpRequest

func (l *Log) HttpRequest(req *http.Request)

some specialized logging for http requests and responses

func (*Log) HttpResponse

func (l *Log) HttpResponse(resp *http.Response, body []byte)

func (*Log) Info

func (l *Log) Info(v ...any)

func (*Log) IsInfo

func (l *Log) IsInfo() bool

func (*Log) IsVerbose

func (l *Log) IsVerbose() bool

func (*Log) Printf

func (l *Log) Printf(format string, v ...any)

func (*Log) Println

func (l *Log) Println(v ...any)

func (*Log) SetDocType

func (l *Log) SetDocType(dt string)

parse and set doc type

func (*Log) SetLevel

func (l *Log) SetLevel(value Level)

func (*Log) Successf

func (l *Log) Successf(format string, v ...any)

type Module

type Module struct {
	Name        string `yaml:"name"`
	ConfigFile  string `yaml:"config"`
	Description string `yaml:"description"`
	ConfigRoot  *parser.Root
}

module config

func GetCurrentModule

func GetCurrentModule() *Module

func GetModule

func GetModule(module string) *Module

func (*Module) LoadConfig

func (m *Module) LoadConfig() error

type ModuleConfig

type ModuleConfig struct {
	Modules []Module `yaml:"modules"`
}

type Profile

type Profile struct {
	Name       string `yaml:"name"`
	ModulesDir string `yaml:"modules_dir"`
}

profile bag holding all configs

type Proxy

type Proxy struct {
	HttpProxy  string `yaml:"http_proxy"`
	HttpsProxy string `yaml:"https_proxy"`
}

proxy config

type Server

type Server struct {
	Addresses map[string]string `yaml:"addresses"`
}

server addresses for destination servers

type TokenCache

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

func GetTokenCache

func GetTokenCache() *TokenCache

access token

func NewTokenCache

func NewTokenCache() *TokenCache

func (*TokenCache) GetToken

func (e *TokenCache) GetToken() string

get token data

func (*TokenCache) Update

func (e *TokenCache) Update(bytes []byte) error

set access token

Jump to

Keyboard shortcuts

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