flagutil

package
v0.35.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

Package flagutil is a helper package for processing and interactive command line flags

Index

Constants

This section is empty.

Variables

Functions

func EnableOutputFlagCompletion

func EnableOutputFlagCompletion(cmd *cobra.Command)

EnableOutputFlagCompletion enables autocompletion for output flag

func EnableStaticFlagCompletion

func EnableStaticFlagCompletion(cmd *cobra.Command, flagName string, validValues []string)

EnableStaticFlagCompletion enables autocompletion for flags with predefined valid values

func FlagDescription

func FlagDescription(localizer localize.Localizer, messageID string, validOptions ...string) string

FlagDescription creates a flag description and adds a list of valid options (if any)

func IsValidInput

func IsValidInput(input string, validValues ...string) bool

IsValidInput checks if the input value is in the range of valid values

func RegisterServiceAccountCompletionFunc

func RegisterServiceAccountCompletionFunc(cmd *cobra.Command, flagName string, connFunc factory.ConnectionFunc) error

RegisterNameFlagCompletionFunc adds the user list to flag dynamic completion

func RegisterUserCompletionFunc

func RegisterUserCompletionFunc(cmd *cobra.Command, flagName string, connFunc factory.ConnectionFunc) error

RegisterUserCompletionFunc adds the user list to flag dynamic completion

Types

type FlagOptions

type FlagOptions struct {
	Required func() error
}

FlagOptions defines additional flag options

func WithFlagOptions

func WithFlagOptions(cmd *cobra.Command, flagName string) *FlagOptions

WithFlagOptions returns additional functions to custom the default flag settings

type FlagSet

type FlagSet struct {
	*pflag.FlagSet
	// contains filtered or unexported fields
}

func NewFlagSet

func NewFlagSet(cmd *cobra.Command, localizer localize.Localizer) *FlagSet

NewFlagSet returns a new flag set with some common flags

func (*FlagSet) AddOutput

func (fs *FlagSet) AddOutput(output *string)

AddOutput adds an output flag to the command

func (*FlagSet) AddPage

func (fs *FlagSet) AddPage(page *int32)

AddPage adds a "page" flag to the command

func (*FlagSet) AddSize

func (fs *FlagSet) AddSize(page *int32)

AddSize adds a "size" flag to the command

func (*FlagSet) AddYes

func (fs *FlagSet) AddYes(yes *bool)

AddYes adds a "yes" flag to the command

Jump to

Keyboard shortcuts

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