common

package
v1.5.5 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2023 License: Apache-2.0 Imports: 36 Imported by: 10

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ArgsCompletionFilter = func(
	cmd *cobra.Command,
	args []string,
	toComplete string,
	completions []string,
	directive cobra.ShellCompDirective,
) ([]string, cobra.ShellCompDirective) {
	args = append(args, toComplete)
	err := cmd.Args(cmd, args)
	if err != nil {
		fmt.Println(err.Error())
		return []string{}, cobra.ShellCompDirectiveError
	}

	return completions, directive
}
View Source
var BoolCompletions = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
	return []string{"true", "false"}, cobra.ShellCompDirectiveDefault
}

Functions

func BoolValidate

func BoolValidate(bool string) error

func BoolValidateOpt added in v1.1.3

func BoolValidateOpt(inp *textinput.TextInput)

func Complete added in v1.2.0

func Complete(
	base CompletionBase,
	filters ...CompletionFilter,
) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)

Complete is a helper function to chain a completion function and subsequent filters.

func FormatDuration added in v1.2.0

func FormatDuration(d time.Duration) string

func FormatField

func FormatField(s string) string

func FormatIntToSI added in v1.1.3

func FormatIntToSI(n uint64, decimals int) string

func GetGroup

func GetGroup(ctx context.Context, identifier string, nc rig.Client) (*group.Group, string, error)

func GetUser

func GetUser(ctx context.Context, identifier string, nc rig.Client) (*user.User, string, error)

func GetUserAndPasswordUpdates

func GetUserAndPasswordUpdates(username, email, phoneNumber, password string) ([]*user.Update, error)

func GetUserIdentifier

func GetUserIdentifier(username, email, phoneNumber string) (*model.UserIdentifier, error)

func GetUserIdentifierUpdates

func GetUserIdentifierUpdates(username, email, phoneNumber string) ([]*user.Update, error)

func ParseUserIdentifier

func ParseUserIdentifier(identifier string) (*model.UserIdentifier, error)

func ParseUserIdentifierUpdate

func ParseUserIdentifierUpdate(identifier string) (*user.Update, error)

func PromptConfirm

func PromptConfirm(label string, def bool) (bool, error)

func PromptInput added in v1.1.3

func PromptInput(label string, opts ...GetInputOption) (string, error)

func PromptPassword added in v1.1.3

func PromptPassword(label string) (string, error)

func PromptSelect

func PromptSelect(label string, choices []string, opts ...SelectInputOption) (int, string, error)

func PromptTableSelect added in v1.2.0

func PromptTableSelect(
	label string,
	choices [][]string,
	columnHeaders []string,
	opts ...SelectInputOption,
) (int, error)

func PromptUserIndentifier

func PromptUserIndentifier() (*model.UserIdentifier, error)

func PromptUserIndentifierUpdate

func PromptUserIndentifierUpdate() (*user.Update, error)

func SelectDontShowResultOpt added in v1.4.0

func SelectDontShowResultOpt(s *selection.Selection[string])

func SelectEnableFilterOpt added in v1.2.0

func SelectEnableFilterOpt(s *selection.Selection[string])

func SelectFuzzyFilterOpt added in v1.2.0

func SelectFuzzyFilterOpt(s *selection.Selection[string])

func ToStringWithSignificantDigits added in v1.1.3

func ToStringWithSignificantDigits(f float64, digits int) string

func ValidateAbsPathOpt added in v1.1.3

func ValidateAbsPathOpt(inp *textinput.TextInput)

func ValidateAbsolutePath added in v1.1.3

func ValidateAbsolutePath(input string) error

func ValidateAll

func ValidateAll(_ string) error

func ValidateAllOpt added in v1.1.3

func ValidateAllOpt(inp *textinput.TextInput)

func ValidateAllowEmpty added in v1.5.2

func ValidateAllowEmpty(validator func(string) error) func(s string) error

func ValidateAnd added in v1.5.2

func ValidateAnd(validators ...func(s string) error) func(s string) error

func ValidateBool added in v1.1.3

func ValidateBool(s string) error

func ValidateBoolOpt added in v1.1.3

func ValidateBoolOpt(inp *textinput.TextInput)

func ValidateCronExpression added in v1.5.2

func ValidateCronExpression(s string) error

func ValidateCronExpressionOpt added in v1.5.2

func ValidateCronExpressionOpt(inp *textinput.TextInput)

func ValidateDuration added in v1.5.2

func ValidateDuration(s string) error

func ValidateDurationOpt added in v1.5.2

func ValidateDurationOpt(inp *textinput.TextInput)

func ValidateEmail

func ValidateEmail(input string) error

func ValidateEmailOpt added in v1.1.3

func ValidateEmailOpt(inp *textinput.TextInput)

func ValidateFilePath added in v1.2.0

func ValidateFilePath(input string) error

func ValidateFilePathOpt added in v1.2.0

func ValidateFilePathOpt(inp *textinput.TextInput)

func ValidateImage

func ValidateImage(input string) error

func ValidateImageOpt added in v1.1.3

func ValidateImageOpt(inp *textinput.TextInput)

func ValidateInt

func ValidateInt(input string) error

func ValidateIntInRange added in v1.5.1

func ValidateIntInRange(minInclusive, maxInclusive int) func(string) error

func ValidateIntOpt added in v1.1.3

func ValidateIntOpt(inp *textinput.TextInput)

func ValidateKubernetesName added in v1.5.1

func ValidateKubernetesName(input string) error

func ValidateKubernetesNameOpt added in v1.5.1

func ValidateKubernetesNameOpt(inp *textinput.TextInput)

func ValidateLength added in v1.5.2

func ValidateLength(minLength, maxLength int) func(string) error

func ValidateNonEmpty

func ValidateNonEmpty(input string) error

func ValidateNonEmptyOpt added in v1.1.3

func ValidateNonEmptyOpt(inp *textinput.TextInput)

func ValidatePasswordOpt added in v1.1.3

func ValidatePasswordOpt(inp *textinput.TextInput)

func ValidatePhoneOpt added in v1.1.3

func ValidatePhoneOpt(inp *textinput.TextInput)

func ValidatePort added in v1.4.0

func ValidatePort(s string) error

func ValidatePortOpt added in v1.4.0

func ValidatePortOpt(inp *textinput.TextInput)

func ValidateQuantity added in v1.1.3

func ValidateQuantity(s string) error

func ValidateQuantityOpt added in v1.1.3

func ValidateQuantityOpt(inp *textinput.TextInput)

func ValidateSystemName

func ValidateSystemName(input string) error

func ValidateSystemNameOpt added in v1.1.3

func ValidateSystemNameOpt(inp *textinput.TextInput)

func ValidateUInt added in v1.5.2

func ValidateUInt(input string) error

func ValidateUIntOpt added in v1.5.2

func ValidateUIntOpt(inp *textinput.TextInput)

func ValidateURL

func ValidateURL(input string) error

func ValidateURLOpt added in v1.1.3

func ValidateURLOpt(inp *textinput.TextInput)

func ValidateURLPathOpt added in v1.5.2

func ValidateURLPathOpt(inp *textinput.TextInput)

func ValidateUnique added in v1.4.0

func ValidateUnique(values []string) func(string) error

Types

type CompletionBase added in v1.5.0

type CompletionBase func(
	cmd *cobra.Command,
	args []string,
	toComplete string,
) ([]string, cobra.ShellCompDirective)

type CompletionFilter added in v1.5.0

type CompletionFilter func(
	cmd *cobra.Command,
	args []string,
	toComplete string,
	current []string,
	directive cobra.ShellCompDirective,
) ([]string, cobra.ShellCompDirective)

func MaxArgsCompletionFilter added in v1.2.0

func MaxArgsCompletionFilter(max int) CompletionFilter

type DeferredOutputCommand added in v1.5.0

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

func NewDefferredOutputCommand added in v1.5.0

func NewDefferredOutputCommand(displayMessage string) *DeferredOutputCommand

func (*DeferredOutputCommand) Command added in v1.5.0

func (d *DeferredOutputCommand) Command(cmd string, args ...string) *DeferredOutputCommand

func (*DeferredOutputCommand) End added in v1.5.0

func (d *DeferredOutputCommand) End(successful bool)

func (*DeferredOutputCommand) Output added in v1.5.0

func (d *DeferredOutputCommand) Output() ([]byte, error)

func (*DeferredOutputCommand) Run added in v1.5.0

func (d *DeferredOutputCommand) Run() error

func (*DeferredOutputCommand) RunNew added in v1.5.0

func (d *DeferredOutputCommand) RunNew(cmd string, args ...string) error

func (*DeferredOutputCommand) Start added in v1.5.0

func (d *DeferredOutputCommand) Start() error

func (*DeferredOutputCommand) StdinPipe added in v1.5.0

func (d *DeferredOutputCommand) StdinPipe() (io.WriteCloser, error)

func (*DeferredOutputCommand) Wait added in v1.5.0

func (d *DeferredOutputCommand) Wait() error

type GetInputOption added in v1.1.3

type GetInputOption = func(*textinput.TextInput)

func InputDefaultOpt added in v1.1.3

func InputDefaultOpt(def string) GetInputOption

func ValidateAllowEmptyOpt added in v1.5.2

func ValidateAllowEmptyOpt(validator func(string) error) GetInputOption

func ValidateAndOpt added in v1.4.0

func ValidateAndOpt(validators ...func(string) error) GetInputOption

func ValidateIntInRangeOpt added in v1.5.1

func ValidateIntInRangeOpt(minInclusive, maxInclusive int) GetInputOption

func ValidateLengthOpt added in v1.5.2

func ValidateLengthOpt(minLength, maxLength int) GetInputOption

func ValidateUniqueOpt added in v1.4.0

func ValidateUniqueOpt(values []string) GetInputOption

type SelectInputOption added in v1.2.0

type SelectInputOption = func(s *selection.Selection[string])

TODO What about non-string Selection

func SelectExtendTemplateOpt added in v1.2.0

func SelectExtendTemplateOpt(t template.FuncMap) SelectInputOption

func SelectTemplateOpt added in v1.2.0

func SelectTemplateOpt(template string) SelectInputOption

Jump to

Keyboard shortcuts

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