flags

package
v1.1.46 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Overview

Package flags contains common utilities for interacting with CLI flags

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(options *Options)

type Options

type Options struct {
	// Prefix prefix all flag names with a string
	Prefix string
	// NoShortHand do not add shorthand flags
	NoShortHand bool
	// Hidden mark flags as hidden (do not show in --help output)
	Hidden bool
}

func AsOptions

func AsOptions(opts []Option) Options

AsOptions converts list of Option functions into an Options

func (Options) Apply

func (f Options) Apply(addTo *pflag.FlagSet, flagBuilder func(set *pflag.FlagSet))

Apply rewrites the flags in the FlagSet in accordance with the given options so that: * flag name is prefixed with the given Prefix * flag name's shorthand flag is removed if NoShortHand is true * flag is hidden if Hidden is true

func (Options) NormalizedFlagName

func (f Options) NormalizedFlagName(baseName string) string

NormalizedFlagName given a flag name, apply prefix if one was configured

Jump to

Keyboard shortcuts

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