Documentation
¶
Index ¶
- Variables
- func Complete(base completionBase, filters ...completionFilter) ...
- func FormatDuration(d time.Duration) string
- func FormatField(s string) string
- func FormatIntToSI(n uint64, decimals int) string
- func GetDatabase(ctx context.Context, identifier string, nc rig.Client) (*database.Database, string, error)
- func GetGroup(ctx context.Context, identifier string, nc rig.Client) (*group.Group, string, error)
- func GetStorageProvider(ctx context.Context, identifier string, nc rig.Client) (*storage.Provider, string, error)
- func GetUser(ctx context.Context, identifier string, nc rig.Client) (*user.User, string, error)
- func GetUserAndPasswordUpdates(username, email, phoneNumber, password string) ([]*user.Update, error)
- func GetUserIdentifier(username, email, phoneNumber string) (*model.UserIdentifier, error)
- func GetUserIdentifierUpdates(username, email, phoneNumber string) ([]*user.Update, error)
- func MaxArgsCompletionFilter(max int) completionFilter
- func ParseUserIdentifier(identifier string) (*model.UserIdentifier, error)
- func ParseUserIdentifierUpdate(identifier string) (*user.Update, error)
- func PromptConfirm(label string, def bool) (bool, error)
- func PromptInput(label string, opts ...GetInputOption) (string, error)
- func PromptPassword(label string) (string, error)
- func PromptSelect(label string, choices []string, opts ...SelectInputOption) (int, string, error)
- func PromptTableSelect(label string, choices [][]string, columnHeaders []string, ...) (int, error)
- func PromptUserIndentifier() (*model.UserIdentifier, error)
- func PromptUserIndentifierUpdate() (*user.Update, error)
- func ProtoToPrettyJson(m protoreflect.ProtoMessage) string
- func ToStringWithSignificantDigits(f float64, digits int) string
- type GetInputOption
- type SelectInputOption
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.ShellCompDirectiveNoFileComp }
View Source
var BoolValidate = func(bool string) error { if bool != "true" && bool != "false" { return errors.InvalidArgumentErrorf("invalid boolean value") } return nil }
View Source
var BoolValidateOpt = func(inp *textinput.TextInput) { inp.Validate = BoolValidate }
View Source
var InputDefaultOpt = func(def string) GetInputOption { return func(inp *textinput.TextInput) { inp.InitialValue = def } }
View Source
var NoCompletions = func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { return []string{}, cobra.ShellCompDirectiveNoFileComp }
View Source
var SelectEnableFilterOpt = func(s *selection.Selection[string]) { s.Filter = selection.FilterContainsCaseSensitive[string] }
View Source
var SelectExtendTemplateOpt = func(t template.FuncMap) SelectInputOption { return func(s *selection.Selection[string]) { s.ExtendedTemplateFuncs = t } }
View Source
var SelectFuzzyFilterOpt = func(s *selection.Selection[string]) { s.Filter = func(filter string, choice *selection.Choice[string]) bool { return fuzzy.Match(filter, choice.Value) } }
View Source
var SelectTemplateOpt = func(template string) SelectInputOption { return func(s *selection.Selection[string]) { s.Template = template } }
View Source
var ValidateAbsPathOpt = func(inp *textinput.TextInput) { inp.Validate = ValidateAbsolutePath }
View Source
var ValidateAbsolutePath = func(input string) error { if abs := path.IsAbs(input); !abs { return errors.InvalidArgumentErrorf("must be an absolute path") } return nil }
View Source
var ValidateAll = func(input string) error { return nil }
View Source
var ValidateAllOpt = func(inp *textinput.TextInput) { inp.Validate = ValidateAll }
View Source
var ValidateBool = func(s string) error { if s == "" { return nil } if _, err := parseBool(s); err != nil { return err } return nil }
View Source
var ValidateBoolOpt = func(inp *textinput.TextInput) { inp.Validate = ValidateBool }
View Source
var ValidateEmail = func(input string) error { _, err := mail.ParseAddress(input) if err != nil { return err } return nil }
View Source
var ValidateEmailOpt = func(inp *textinput.TextInput) { inp.Validate = ValidateEmail }
View Source
var ValidateFilePath = func(input string) error { if path.Ext(input) == "" { return errors.InvalidArgumentErrorf("must be a file path") } return nil }
View Source
var ValidateFilePathOpt = func(inp *textinput.TextInput) { inp.Validate = ValidateFilePath }
View Source
var ValidateImage = func(input string) error { _, err := reference.ParseDockerRef(input) if err != nil { return err } return nil }
View Source
var ValidateImageOpt = func(inp *textinput.TextInput) { inp.Validate = ValidateImage }
View Source
var ValidateInt = func(input string) error { _, err := strconv.Atoi(input) if err != nil { return err } return nil }
View Source
var ValidateIntOpt = func(inp *textinput.TextInput) { inp.Validate = ValidateInt }
View Source
var ValidateNonEmpty = func(input string) error { if input == "" { return errors.InvalidArgumentErrorf("value cannot be empty") } return nil }
View Source
var ValidateNonEmptyOpt = func(inp *textinput.TextInput) { inp.Validate = ValidateNonEmpty }
View Source
var ValidatePasswordOpt = func(inp *textinput.TextInput) { inp.Validate = utils.ValidatePassword }
View Source
var ValidatePhoneOpt = func(inp *textinput.TextInput) { inp.Validate = utils.ValidatePhone }
View Source
var ValidateQuantity = func(s string) error { _, err := resource.ParseQuantity(s) return err }
View Source
var ValidateQuantityOpt = func(inp *textinput.TextInput) { inp.Validate = ValidateQuantity }
View Source
var ValidateSystemName = func(input string) error { if l := len(input); l < 3 || l > 63 { return errors.InvalidArgumentErrorf("must be between 3 and 63 characters long") } if !regexp.MustCompile(`^[a-z][a-z0-9-]+[a-z0-9]$`).MatchString(input) { return errors.InvalidArgumentErrorf("invalid name; can only contain a-z, 0-9 and '-'") } return nil }
View Source
var ValidateSystemNameOpt = func(inp *textinput.TextInput) { inp.Validate = ValidateSystemName }
View Source
var ValidateURL = func(input string) error { _, err := url.Parse(input) return err }
View Source
var ValidateURLOpt = func(inp *textinput.TextInput) { inp.Validate = ValidateURL }
Functions ¶
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 GetDatabase ¶
func GetStorageProvider ¶
func GetUserIdentifier ¶
func GetUserIdentifier(username, email, phoneNumber string) (*model.UserIdentifier, error)
func MaxArgsCompletionFilter ¶ added in v1.2.0
func MaxArgsCompletionFilter(max int) completionFilter
func ParseUserIdentifier ¶
func ParseUserIdentifier(identifier string) (*model.UserIdentifier, error)
func PromptInput ¶ added in v1.1.3
func PromptInput(label string, opts ...GetInputOption) (string, error)
func PromptPassword ¶ added in v1.1.3
func PromptSelect ¶
func PromptTableSelect ¶ added in v1.2.0
func PromptUserIndentifier ¶
func PromptUserIndentifier() (*model.UserIdentifier, error)
func ProtoToPrettyJson ¶
func ProtoToPrettyJson(m protoreflect.ProtoMessage) string
func ToStringWithSignificantDigits ¶ added in v1.1.3
Types ¶
type GetInputOption ¶ added in v1.1.3
type SelectInputOption ¶ added in v1.2.0
TODO What about non-string Selection
Click to show internal directories.
Click to hide internal directories.