flags

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package flags manages command-line flag binding and configuration for godyl.

It provides utilities for binding cobra flags to viper configuration and defines standardized flag sets for different command types. This package handles environment variable integration, flag parsing, and configuration unmarshalling to ensure consistent behavior across all commands.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bind

func Bind(cmd *cobra.Command, cfg Viperable, prefix ...string) error

Bind connects cobra flags to viper and unmarshals the configuration into the provided struct. It sets up environment variable handling with the given prefix and handles flag binding. Omit the prefix to use the command hierarchy as the prefix.

func ChainPreRun added in v0.0.4

func ChainPreRun(cmd *cobra.Command, s Viperable, prefix ...string) error

ChainPreRun is a helper function to chain the PreRunE functions of a command and its parent.

func PrefixToYAML added in v0.0.11

func PrefixToYAML(prefix, root string) string

func Root

func Root(cmd *cobra.Command)

Root adds the root-level command flags to the provided cobra command. These flags apply to the root command.

func Status added in v0.0.11

func Status(cmd *cobra.Command)

Status adds status-related command flags to the provided cobra command.

func Tool

func Tool(cmd *cobra.Command)

Tool adds tool-related command flags to the provided cobra command. These flags control how tools are downloaded and installed.

func Trim added in v0.0.11

func Trim(file file.File, prefix string) (io.Reader, error)

Trim reads a YAML file and returns an io.Reader with only the content under the specified prefix, with the prefix itself removed.

func Update

func Update(cmd *cobra.Command)

Update adds update-related command flags to the provided cobra command. These flags control the self-update.

Types

type Viperable added in v0.0.8

type Viperable interface {
	SetViper(v *viper.Viper)
	GetViper() *viper.Viper
}

Viperable is an interface for types that can hold a viper instance.

Jump to

Keyboard shortcuts

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