utils

package
v1.1.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Build string
	Major string
	Minor string
	Patch string

	CLIVersion Version
)

Functions

func BindLegacyEnv

func BindLegacyEnv(w io.Writer)

BindLegacyEnv binds config keys to their HOSTINGER_MAIL_* env var with a deprecated HAPI_* fallback on the global viper, emitting a one-time notice to w per key whose value comes from the legacy variable.

func EnumCheck

func EnumCheck(cmd *cobra.Command, flag string, allowed []string)

EnumCheck validates that a changed string flag holds one of the allowed values.

func IntPtrOrNil

func IntPtrOrNil(i int) *int

func JSONValue

func JSONValue(raw, flag string) any

JSONValue parses a JSON-string flag value into a generic value.

func MigrateLegacyConfig

func MigrateLegacyConfig(home string, w io.Writer) (configPath string, migrated bool)

MigrateLegacyConfig returns the YAML config path the CLI should read and whether a one-time migration (or legacy fallback) happened. When the new ~/.hostinger-mail.yaml is absent but a legacy ~/.hapi.yaml exists, it moves the old file to the new path. If the move fails, it falls back to the old path in place. Notices are written to w. With no legacy file, it is a no-op.

func StringArrayToIntArray

func StringArrayToIntArray(strArr []string) []int

func StringPtrOrNil

func StringPtrOrNil(s string) *string

func StringToDate added in v1.1.2

func StringToDate(dateStr string) openapi_types.Date

func StringToEmail added in v1.1.2

func StringToEmail(email string) openapi_types.Email

StringToEmail keeps format:email query params converting through utils like every other formatted kind, so generated commands need no extra import.

func StringToInt

func StringToInt(s string) int

func StringToTime

func StringToTime(dateStr string) time.Time

func StringToUUID added in v1.1.4

func StringToUUID(s string) openapi_types.UUID

Types

type Version

type Version struct {
	Major, Minor, Patch int
	Build               string
}

func (Version) String

func (v Version) String(withBuild bool) string

Jump to

Keyboard shortcuts

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