utils

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DiagInvalid hcl.DiagnosticSeverity = iota
	DiagError
	DiagWarning
	DiagInfo
	DiagDebug
)

Variables

View Source
var ErrSilent = errors.New("ErrSilent")
View Source
var (

	// Root folder of this project
	ProjectRoot = filepath.Join(filepath.Dir(b), "../..")
)

Functions

func All

func All[T any](s []T, test func(T) bool) bool

func Any

func Any[T any](s []T, test func(T) bool) bool

func AssertPanic

func AssertPanic(t *testing.T, f func())

func Bool

func Bool(v bool) *bool

func Contains

func Contains(s []string, v string) bool

func ExecuteCommand

func ExecuteCommand(root *cobra.Command, args ...string) (c *cobra.Command, output string, err error)

func ExecuteCommandErr

func ExecuteCommandErr(root *cobra.Command, args ...string) (c *cobra.Command, output string, errOutput string, err error)

func Filter

func Filter[T any](s []T, test func(T) bool) []T

func FormatMap

func FormatMap(m map[string]string, separator string, alignRight bool) string

func GetCaptures

func GetCaptures(re *regexp.Regexp, findAll bool, capture string, s string) ([]string, error)

"findAll" gives back multiple matches. if set to false, only the first match is captured capture is either the group index as a string or the group name

func GetURLsFromArgs

func GetURLsFromArgs(args []string) ([]string, hcl.Diagnostics)

func HasNamedCaptures

func HasNamedCaptures(re *regexp.Regexp) (bool, []string)

func Int

func Int(v int) *int

func ParseURLList

func ParseURLList(contents, filename string) ([]string, hcl.Diagnostics)

func Plural

func Plural(count int, singular string, plural string) string

func PrintDiag

func PrintDiag(w io.Writer, diag *hcl.Diagnostic)

func String

func String(v string) *string

func Unique

func Unique(s []string) []string

func ZipMap

func ZipMap(keys []string, values []string) map[string]string

Types

This section is empty.

Jump to

Keyboard shortcuts

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