prompts

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Prompts
	BranchPrompt        = "Branch:"
	CommitMessagePrompt = "Commit Message:"
	DescriptionPrompt   = "Description:"
	EntryPointPrompt    = "Entry Point:"

	MemoryPrompt           = "Memory:"
	PathsPrompt            = "Paths [comma separated]:"
	SizePrompt             = "Size:"
	TTLPrompt              = "TTL:"
	UnitTypePrompt         = "Unit type:"
	TrueSelect             = "True"
	TrueSelectL            = "true"
	FalseSelect            = "False"
	FalseSelectL           = "false"
	TagsPrompt             = "Tags [comma separated]:"
	RegexPrompt            = "Use Regex For Match:"
	LocalPrompt            = "Local:"
	GenerateRepoPrompt     = "Generate a Repository:"
	UseTemplatePrompt      = "Use a Template:"
	SelectTemplatePrompt   = "Select a Template:"
	RepositoryNamePrompt   = "Repository Name:"
	RepositorySelectPrompt = "Select a Repository"
	ClonePrompt            = "Clone this Repository"
	Domains                = "Domains:"
	EmbedTokenPrompt       = "Embed Git Token Into Clone URL:"
	BranchSelectPrompt     = "Select a Branch:"
	PrivatePrompt          = "Private:"
	SourcePrompt           = "Code source:"
	CodeLanguagePrompt     = "Code Language:"
	CallPrompt             = "Entry Point:"
	TimeoutPrompt          = "Time To Live:"

	NetworkPrompts = "Network:"
	FQDN           = "FQDN:"
	Universe       = "Universe:"

	NoDomainGeneratePrompt = "No domains found, generate one?"

	// Error messages
	Required                   = "Required"
	MustBeABooleanValue        = "Must be a boolean value"
	FieldNotDefinedInConfig    = "field not defined in config: %#v"
	DoubleStringNotFound       = "%s %s not found"
	StringIsRequired           = "%s is required"
	StringIsNotAValidSelection = "`%s` not a valid selection: %v"
	InvalidSize                = "invalid size: %s Ex:(10, 10GB, 10PB)"
	SelectPromptNoOptions      = "no options to select from for prompt: %s"
	NoServiceFromFlag          = "unable to find service with selection: (--%s %s)"

	//    Device Errors
	TagLessThanThreeCharacters = "Tags cannot be less than three characters"
)

Variables

View Source
var (
	ErrorNoServicesDefined = errors.New("no services defined in project config")
	ErrorNoValidDomains    = errors.New("no valid domains")
)

Errors

View Source
var PromptEnabled = true
View Source
var (
	SelectionNone = "(none)"
)

Functions

func Ask

func Ask(qs []*survey.Question, response interface{}, opts ...survey.AskOpt)

func AskOne

func AskOne(p survey.Prompt, response interface{}, opts ...survey.AskOpt)

func ConfirmData

func ConfirmData(c *cli.Context, label string, data [][]string) bool

func ConfirmDataWithMerge

func ConfirmDataWithMerge(c *cli.Context, label string, data [][]string) bool

func ConfirmPrompt

func ConfirmPrompt(c *cli.Context, label string) bool

func GetClone

func GetClone(ctx *cli.Context, prev ...bool) bool

func GetGenerateRepository

func GetGenerateRepository(ctx *cli.Context, prev ...bool) bool

func GetMatchRegex

func GetMatchRegex(ctx *cli.Context, prev ...bool) bool

func GetOrAskForADescription

func GetOrAskForADescription(c *cli.Context, prev ...string) string

func GetOrAskForAStringValue

func GetOrAskForAStringValue(c *cli.Context, field string, label string, prev ...string) string

func GetOrAskForBool

func GetOrAskForBool(c *cli.Context, field string, label string, prev ...bool) bool

func GetOrAskForBoolDefaultTrue

func GetOrAskForBoolDefaultTrue(c *cli.Context, field string, label string, prev ...bool) bool

func GetOrAskForEmbedToken

func GetOrAskForEmbedToken(ctx *cli.Context, prev ...bool) bool

func GetOrAskForEnvironmentVars

func GetOrAskForEnvironmentVars(c *cli.Context, prev ...map[string]string) map[string]string

Unused, was used in devices

func GetOrAskForLocal

func GetOrAskForLocal(ctx *cli.Context, prev ...bool) bool

func GetOrAskForSelection

func GetOrAskForSelection(c *cli.Context, field string, label string, items []string, prev ...string) string

func GetOrAskForTags

func GetOrAskForTags(c *cli.Context, prev ...[]string) (ret []string)

func GetOrRequireABranch

func GetOrRequireABranch(c *cli.Context, prev ...string) string

func GetOrRequireACall

func GetOrRequireACall(c *cli.Context, source common.Source, prev ...string) string

TODO parse the source, and make this a selection based on exported functions.

func GetOrRequireACommitMessage

func GetOrRequireACommitMessage(c *cli.Context) (ret string)

func GetOrRequireAMatch

func GetOrRequireAMatch(c *cli.Context, prompt string, prev ...string) string

func GetOrRequireAName

func GetOrRequireAName(c *cli.Context, prompt string, prev ...string) string

func GetOrRequireAPath

func GetOrRequireAPath(c *cli.Context, prompt string, prev ...string) string

func GetOrRequireARepositoryName

func GetOrRequireARepositoryName(ctx *cli.Context, prev ...string) string

func GetOrRequireAString

func GetOrRequireAString(c *cli.Context, field, prompt string, validator validateStringMethod, prev ...string) string

func GetOrRequireATimeout

func GetOrRequireATimeout(ctx *cli.Context, prev ...uint64) (uint64, error)

func GetOrRequireAUniqueName

func GetOrRequireAUniqueName(c *cli.Context, prompt string, invalid []string, prev ...string) string

func GetOrRequireAnEntryPoint

func GetOrRequireAnEntryPoint(c *cli.Context, prev ...string) string

func GetOrRequireMemoryAndType

func GetOrRequireMemoryAndType(ctx *cli.Context, new bool, prev ...uint64) (uint64, error)

func GetOrSelectDomainsWithFQDN

func GetOrSelectDomainsWithFQDN(ctx *cli.Context, prev ...string) ([]string, error)

func GetOrSelectLanguage

func GetOrSelectLanguage(ctx *cli.Context, prev ...string) (string, error)

func GetOrSelectSource

func GetOrSelectSource(ctx *cli.Context, prev ...string) (common.Source, error)

func GetPrivate

func GetPrivate(ctx *cli.Context, prev ...bool) bool

func GetSizeAndType

func GetSizeAndType(c *cli.Context, oldSize string, isNew bool) (size string)

TODO should take and return expected type

func GetUseACodeTemplate

func GetUseACodeTemplate(ctx *cli.Context) bool

func MultiSelect

func MultiSelect(c *cli.Context, cnf MultiSelectConfig) (ret []string)

func NeedGenerateDomain

func NeedGenerateDomain(ctx *cli.Context) error

NeedGenerateDomain checks for available domains if none found asks the user if they would like to generate one; returns an error

func PanicIfPromptNotEnabled

func PanicIfPromptNotEnabled(prompt string)

func RenderTable

func RenderTable(data [][]string)

func RenderTableWithMerge

func RenderTableWithMerge(data [][]string)

func RequiredPaths

func RequiredPaths(c *cli.Context, prev ...string) (ret []string)

func RequiredString

func RequiredString(c *cli.Context, prompt string, f stringPromptMethod, prev ...string) string

func RequiredStringWithValidator

func RequiredStringWithValidator(c *cli.Context, prompt string, f stringPromptMethod, validator validateStringMethod, prev ...string) (ret string)

func RequiredTags

func RequiredTags(c *cli.Context, prev ...[]string) (ret []string)

func SelectABranch

func SelectABranch(c *cli.Context, repo *git.Repository) (branch string, err error)

func SelectARepository

func SelectARepository(ctx *cli.Context, prev *repositoryLib.Info) (*repositoryLib.Info, error)

repository-id || repository-name/full-name

func SelectARepositoryFromGithub

func SelectARepositoryFromGithub() (common.Repository, error)

func SelectAServiceWithProtocol

func SelectAServiceWithProtocol(ctx *cli.Context, field string, prompt string, prev ...string) (string, error)

func SelectATemplate

func SelectATemplate(ctx *cli.Context, templateMap map[string]templates.TemplateInfo, prevURL ...string) (url string, err error)

func SelectInterface

func SelectInterface(names []string, prompt, _default string) (selectedInterface string, err error)

func SelectInterfaceField

func SelectInterfaceField(ctx *cli.Context, options []string, field string, prompt string, prev ...string) (selected string, err error)

func ValidateOk

func ValidateOk(err error) bool

Types

type MultiSelectConfig

type MultiSelectConfig struct {
	Field    string
	Prompt   string
	Options  []string
	Previous []string
	Required bool
}

Jump to

Keyboard shortcuts

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