common

package
v0.0.18-beta Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExitOnShow added in v0.0.13

func ExitOnShow(show root.ShowFuncType, args ...string) bool

func KCreateSubcommandPreRunE added in v0.0.13

func KCreateSubcommandPreRunE(
	cmd *cobra.Command,
	cfg Trackable,
	show root.ShowFuncType,
) func(_ *cobra.Command, _ []string) error

func SetSubcommandDefaults added in v0.0.13

func SetSubcommandDefaults(cmd *cobra.Command, local any, show root.ShowFuncType)

func SetupLogger added in v0.0.13

func SetupLogger(level string) (*logger.Logger, error)

Types

type CommandPath added in v0.0.13

type CommandPath []string

func BuildCommandPath added in v0.0.13

func BuildCommandPath(cmd *cobra.Command) CommandPath

func (CommandPath) Env added in v0.0.13

func (c CommandPath) Env() iutils.Prefix

func (CommandPath) Section added in v0.0.13

func (c CommandPath) Section() iutils.Prefix

func (CommandPath) WithoutRoot added in v0.0.13

func (c CommandPath) WithoutRoot() CommandPath

type Context added in v0.0.13

type Context struct {
	// Config holds a map of the parsed configuration file.
	Config *koanfx.Koanf
	// DotEnv holds the parsed .env files
	DotEnv *env.Env
	// Env holds the parsed environment variables.
	Env *env.Env
}

Context holds the parsed configuration.

var GlobalContext Context

GlobalContext is a global variable, allowing the root parsed configuration to be accessed from anywhere in the application.

type Embedded added in v0.0.13

type Embedded struct {
	// Defaults to be set for each tool (not flags).
	Defaults []byte
	// Default list of tools that can be used to either view or dump out.
	Tools []byte
	// A template for the cleanup script.
	Template []byte
}

Embedded holds the embedded files for the application.

func NewEmbeddedFiles added in v0.0.13

func NewEmbeddedFiles(embeds embed.FS) (*Embedded, error)

NewEmbeddedFiles loads embedded configuration files and templates.

type Handler added in v0.0.13

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

func NewHandler added in v0.0.13

func NewHandler(cfg root.Config, embedded Embedded) *Handler

func (*Handler) Logger added in v0.0.13

func (c *Handler) Logger() *logger.Logger

func (*Handler) Resolve added in v0.0.13

func (c *Handler) Resolve(defaultFile file.File, tools *tools.Tools) (err error)

func (*Handler) SetupLogger added in v0.0.13

func (c *Handler) SetupLogger(level string) (err error)

type Input added in v0.0.13

type Input struct {
	// Global contains the global configuration.
	Global *root.Config
	// Embedded contains the embedded configuration.
	Embedded *Embedded
	// Cmd is the current command being executed.
	Cmd *cobra.Command
	// Args are the arguments passed to the command.
	Args []string
}

Input is the input structure for the CLI commands.

func (Input) Unpack added in v0.0.13

func (i Input) Unpack() (*root.Config, *Embedded, *Context, *cobra.Command, []string)

Unpack is a convenience method to unpack the Input structure into its components.

type Trackable added in v0.0.13

type Trackable interface {
	Store(tracker *koanfx.Tracker)
	Validate() error
}

Jump to

Keyboard shortcuts

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