Documentation ¶
Index ¶
- Constants
- Variables
- func BoolValidate(bool string) error
- func BoolValidateOpt(inp *textinput.TextInput)
- func ChainCompletions(numArgs []int, chain ...CompletionBase) ...
- func Complete(base CompletionBase, filters ...CompletionFilter) ...
- func Format(v any, outputType OutputType) (string, error)
- func FormatDuration(d time.Duration) string
- func FormatField(s string) string
- func FormatIntToSI(n uint64, decimals int) string
- func FormatPrint(v any, o OutputType) error
- func FormatTime(t time.Time) string
- func GetAllAnnotations(cmd *cobra.Command) map[string]string
- func GetGroup(ctx context.Context, id string, nc rig.Client, p Prompter) (*group.Group, string, error)
- func GetMember(ctx context.Context, rc rig.Client, p Prompter) (string, string, []string, error)
- func GetUser(ctx context.Context, identifier string, rc rig.Client, p Prompter) (*user.User, string, error)
- func ParseUserIdentifier(identifier string) (*model.UserIdentifier, error)
- func RoleCompletions(_ *cobra.Command, _ []string, toComplete string) ([]string, cobra.ShellCompDirective)
- func SelectDontShowResultOpt(s *selection.Selection[string])
- func SelectEnableFilterOpt(s *selection.Selection[string])
- func SelectFuzzyFilterOpt(s *selection.Selection[string])
- func ToStringWithSignificantDigits(f float64, digits int) string
- func UserIndentifier(p Prompter) (*model.UserIdentifier, error)
- func ValidateAbsPathOpt(inp *textinput.TextInput)
- func ValidateAbsolutePath(input string) error
- func ValidateAll(_ string) error
- func ValidateAllOpt(inp *textinput.TextInput)
- func ValidateAllowEmpty(validator func(string) error) func(s string) error
- func ValidateAnd(validators ...func(s string) error) func(s string) error
- func ValidateBool(s string) error
- func ValidateBoolOpt(inp *textinput.TextInput)
- func ValidateCronExpression(s string) error
- func ValidateCronExpressionOpt(inp *textinput.TextInput)
- func ValidateDuration(s string) error
- func ValidateDurationOpt(inp *textinput.TextInput)
- func ValidateEmail(input string) error
- func ValidateEmailOpt(inp *textinput.TextInput)
- func ValidateFilePath(input string) error
- func ValidateFilePathOpt(inp *textinput.TextInput)
- func ValidateImage(input string) error
- func ValidateImageOpt(inp *textinput.TextInput)
- func ValidateInt(input string) error
- func ValidateIntInRange(minInclusive, maxInclusive int) func(string) error
- func ValidateIntOpt(inp *textinput.TextInput)
- func ValidateKubernetesName(input string) error
- func ValidateKubernetesNameOpt(inp *textinput.TextInput)
- func ValidateLength(minLength, maxLength int) func(string) error
- func ValidateNonEmpty(input string) error
- func ValidateNonEmptyOpt(inp *textinput.TextInput)
- func ValidatePasswordOpt(inp *textinput.TextInput)
- func ValidatePhoneOpt(inp *textinput.TextInput)
- func ValidatePort(s string) error
- func ValidatePortOpt(inp *textinput.TextInput)
- func ValidateQuantity(s string) error
- func ValidateQuantityOpt(inp *textinput.TextInput)
- func ValidateSystemName(input string) error
- func ValidateSystemNameOpt(inp *textinput.TextInput)
- func ValidateUInt(input string) error
- func ValidateUIntOpt(inp *textinput.TextInput)
- func ValidateURL(input string) error
- func ValidateURLOpt(inp *textinput.TextInput)
- func ValidateURLPathOpt(inp *textinput.TextInput)
- func ValidateUnique(values []string) func(string) error
- type CompletionBase
- type CompletionFilter
- type DeferredOutputCommand
- func (d *DeferredOutputCommand) Command(cmd string, args ...string) *DeferredOutputCommand
- func (d *DeferredOutputCommand) End(successful bool)
- func (d *DeferredOutputCommand) Output() ([]byte, error)
- func (d *DeferredOutputCommand) Run() error
- func (d *DeferredOutputCommand) RunNew(cmd string, args ...string) error
- func (d *DeferredOutputCommand) Start() error
- func (d *DeferredOutputCommand) StdinPipe() (io.WriteCloser, error)
- func (d *DeferredOutputCommand) Wait() error
- type GetInputOption
- func InputDefaultOpt(def string) GetInputOption
- func ValidateAllowEmptyOpt(validator func(string) error) GetInputOption
- func ValidateAndOpt(validators ...func(string) error) GetInputOption
- func ValidateIntInRangeOpt(minInclusive, maxInclusive int) GetInputOption
- func ValidateLengthOpt(minLength, maxLength int) GetInputOption
- func ValidateUniqueOpt(values []string) GetInputOption
- type OutputType
- type Prompter
- type SelectInputOption
- type StandardPrompter
- func (StandardPrompter) Confirm(label string, def bool) (bool, error)
- func (StandardPrompter) Input(label string, opts ...GetInputOption) (string, error)
- func (StandardPrompter) Password(label string) (string, error)
- func (StandardPrompter) Select(label string, choices []string, opts ...SelectInputOption) (int, string, error)
- func (p StandardPrompter) TableSelect(label string, choices [][]string, columnHeaders []string, ...) (int, error)
Constants ¶
const ( AuthGroupID = "auth" OtherGroupID = "other" CapsuleGroupID = "capsule" ManagementGroupID = "management" )
const ( AuthGroupTitle = "Authentication Commands - Manage access to Rig" OtherGroupTitle = "Other Commands" CapsuleGroupTitle = "Capsule Commands - Capsules and their deployments" ManagementGroupTitle = "Management Commands - Manage everything around capsules" )
Variables ¶
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 { return []string{}, cobra.ShellCompDirectiveError } return completions, directive }
var BoolCompletions = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return []string{"true", "false"}, cobra.ShellCompDirectiveDefault }
Functions ¶
func BoolValidate ¶
func BoolValidateOpt ¶ added in v1.1.3
func ChainCompletions ¶ added in v1.8.12
func ChainCompletions( numArgs []int, chain ...CompletionBase, ) func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective)
ChainCompletions is a helper function to chain multiple completion functions. i.e. provide a number of arguments from each completion function. numArgs is a running sum of the number of arguments each completion function provides. i.e. [1, 2, 4] means first function provides argument 1, second function provides argument 2, and third function provides arguments 3 and 4. The length of numArgs must match the length of the completion chain.
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 FormatField ¶
func FormatIntToSI ¶ added in v1.1.3
func FormatPrint ¶ added in v1.6.1
func FormatPrint(v any, o OutputType) error
func FormatTime ¶ added in v1.6.4
func GetAllAnnotations ¶ added in v1.6.1
func ParseUserIdentifier ¶
func ParseUserIdentifier(identifier string) (*model.UserIdentifier, error)
func RoleCompletions ¶ added in v1.6.2
func SelectDontShowResultOpt ¶ added in v1.4.0
func SelectEnableFilterOpt ¶ added in v1.2.0
func SelectFuzzyFilterOpt ¶ added in v1.2.0
func ToStringWithSignificantDigits ¶ added in v1.1.3
func UserIndentifier ¶ added in v1.8.11
func UserIndentifier(p Prompter) (*model.UserIdentifier, error)
func ValidateAbsPathOpt ¶ added in v1.1.3
func ValidateAbsolutePath ¶ added in v1.1.3
func ValidateAll ¶
func ValidateAllOpt ¶ added in v1.1.3
func ValidateAllowEmpty ¶ added in v1.5.2
func ValidateAnd ¶ added in v1.5.2
func ValidateBool ¶ added in v1.1.3
func ValidateBoolOpt ¶ added in v1.1.3
func ValidateCronExpression ¶ added in v1.5.2
func ValidateCronExpressionOpt ¶ added in v1.5.2
func ValidateDuration ¶ added in v1.5.2
func ValidateDurationOpt ¶ added in v1.5.2
func ValidateEmail ¶
func ValidateEmailOpt ¶ added in v1.1.3
func ValidateFilePath ¶ added in v1.2.0
func ValidateFilePathOpt ¶ added in v1.2.0
func ValidateImage ¶
func ValidateImageOpt ¶ added in v1.1.3
func ValidateInt ¶
func ValidateIntInRange ¶ added in v1.5.1
func ValidateIntOpt ¶ added in v1.1.3
func ValidateKubernetesName ¶ added in v1.5.1
func ValidateKubernetesNameOpt ¶ added in v1.5.1
func ValidateLength ¶ added in v1.5.2
func ValidateNonEmpty ¶
func ValidateNonEmptyOpt ¶ added in v1.1.3
func ValidatePasswordOpt ¶ added in v1.1.3
func ValidatePhoneOpt ¶ added in v1.1.3
func ValidatePort ¶ added in v1.4.0
func ValidatePortOpt ¶ added in v1.4.0
func ValidateQuantity ¶ added in v1.1.3
func ValidateQuantityOpt ¶ added in v1.1.3
func ValidateSystemName ¶
func ValidateSystemNameOpt ¶ added in v1.1.3
func ValidateUInt ¶ added in v1.5.2
func ValidateUIntOpt ¶ added in v1.5.2
func ValidateURL ¶
func ValidateURLOpt ¶ added in v1.1.3
func ValidateURLPathOpt ¶ added in v1.5.2
func ValidateUnique ¶ added in v1.4.0
Types ¶
type CompletionBase ¶ added in v1.5.0
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 AddValidArgsCompletionFilter ¶ added in v1.8.12
func AddValidArgsCompletionFilter(validArgs ...string) CompletionFilter
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 NewDeferredOutputCommand ¶ added in v1.7.0
func NewDeferredOutputCommand(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
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 OutputType ¶ added in v1.6.1
type OutputType string
const ( OutputTypeJSON OutputType = "json" OutputTypeYAML OutputType = "yaml" OutputTypePretty OutputType = "pretty" )
func (*OutputType) Set ¶ added in v1.6.1
func (e *OutputType) Set(v string) error
Set must have pointer receiver so it doesn't change the value of a copy
func (*OutputType) String ¶ added in v1.6.1
func (e *OutputType) String() string
String is used both by fmt.Print and by Cobra in help text
func (*OutputType) Type ¶ added in v1.6.1
func (e *OutputType) Type() string
Type is only used in help text
type Prompter ¶ added in v1.8.10
type Prompter interface { Input(label string, opts ...GetInputOption) (string, error) Password(label string) (string, error) Select(label string, choices []string, opts ...SelectInputOption) (int, string, error) Confirm(label string, def bool) (bool, error) TableSelect( label string, choices [][]string, columnHeaders []string, opts ...SelectInputOption, ) (int, error) }
type SelectInputOption ¶ added in v1.2.0
TODO What about non-string Selection
func SelectExtendTemplateOpt ¶ added in v1.2.0
func SelectExtendTemplateOpt(t template.FuncMap) SelectInputOption
func SelectPageSizeOpt ¶ added in v1.7.2
func SelectPageSizeOpt(size int) SelectInputOption
func SelectTemplateOpt ¶ added in v1.2.0
func SelectTemplateOpt(template string) SelectInputOption
type StandardPrompter ¶ added in v1.8.11
type StandardPrompter struct{}
func (StandardPrompter) Confirm ¶ added in v1.8.11
func (StandardPrompter) Confirm(label string, def bool) (bool, error)
func (StandardPrompter) Input ¶ added in v1.8.11
func (StandardPrompter) Input(label string, opts ...GetInputOption) (string, error)
func (StandardPrompter) Password ¶ added in v1.8.11
func (StandardPrompter) Password(label string) (string, error)
func (StandardPrompter) Select ¶ added in v1.8.11
func (StandardPrompter) Select(label string, choices []string, opts ...SelectInputOption) (int, string, error)
func (StandardPrompter) TableSelect ¶ added in v1.8.11
func (p StandardPrompter) TableSelect( label string, choices [][]string, columnHeaders []string, opts ...SelectInputOption, ) (int, error)