shared

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Version = "unknown" //nolint:gochecknoglobals
	Commit  = "unknown" //nolint:gochecknoglobals
)

These will be set at build time with ldflags, see Justfile for how they're defined and passed.

View Source
var DocsLink = color.New(color.Faint).Sprint(
	"Docs: https://github.com/peterldowns/pgmigrate",
)

Functions

func CLIExample

func CLIExample(s string) string

CLIExample is a helper for generating CLI example docs for cobra commands. It removes any surrounding space from a string, then removes any leading whitespace from each line in the string. Any comments in the string will be colored as fainter than the rest of the text.

func CLIHelp added in v0.0.4

func CLIHelp(s string) string

func CLIShort added in v0.0.4

func CLIShort(s string) string

func CheckPath added in v0.0.5

func CheckPath(p string) string

func RepoPath added in v0.0.5

func RepoPath(p string) string

func Validate

func Validate(vars ...Required) error

func VersionString

func VersionString() string

Types

type Config

type Config struct {
	Database   string        `yaml:"database"`
	Migrations string        `yaml:"migrations"`
	LogFormat  LogFormat     `yaml:"log_format"`
	TableName  string        `yaml:"table_name"`
	Schema     schema.Config `yaml:"schema"`
}

type Flags

type Flags struct {
	LogFormat  *string // see logger.go
	Database   *string // see root.go
	Migrations *string // see root.go
	TableName  *string // see root.go
	ConfigFile *string // see root.go
}

type LogAdapter

type LogAdapter struct {
	*log.Logger
}

func (LogAdapter) Log

func (l LogAdapter) Log(_ context.Context, level pgmigrate.LogLevel, msg string, fields ...pgmigrate.LogField)

type LogFormat

type LogFormat string
const (
	LogFormatJSON LogFormat = "json"
	LogFormatText LogFormat = "text"
)

type Required

type Required interface {
	Name() string
	IsSet() bool
}

type StateT

type StateT struct {
	Flags  Flags
	Config Config
}
var State StateT

func (StateT) Configfile

func (state StateT) Configfile() Variable[string]

func (StateT) Database

func (state StateT) Database() Variable[string]

func (StateT) LogFormat

func (state StateT) LogFormat() Variable[LogFormat]

func (StateT) Logger

func (state StateT) Logger() (*log.Logger, LogAdapter)

func (StateT) Migrations

func (state StateT) Migrations() Variable[string]

func (*StateT) Parse

func (state *StateT) Parse()

func (StateT) TableName added in v0.0.3

func (state StateT) TableName() Variable[string]

type Variable

type Variable[T comparable] struct {
	// contains filtered or unexported fields
}

func NewVariable

func NewVariable[T comparable](name string, values ...T) Variable[T]

func (Variable[T]) IsSet

func (s Variable[T]) IsSet() bool

func (Variable[T]) Name

func (s Variable[T]) Name() string

func (Variable[T]) Value

func (s Variable[T]) Value() T

Jump to

Keyboard shortcuts

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