MCPcopy Index your code
hub / github.com/coder/coder / promptForStringVariable

Function promptForStringVariable

cli/templatepush.go:657–671  ·  view source on GitHub ↗
(inv *serpent.Invocation, variable codersdk.TemplateVersionVariable)

Source from the content-addressed store, hash-verified

655}
656
657func promptForStringVariable(inv *serpent.Invocation, variable codersdk.TemplateVersionVariable) (string, error) {
658 prompt := "Enter value:"
659 if !variable.Sensitive {
660 if !variable.Required && variable.DefaultValue != "" {
661 prompt = fmt.Sprintf("Enter value (default: %q):", variable.DefaultValue)
662 }
663 }
664
665 return cliui.Prompt(inv, cliui.PromptOptions{
666 Text: prompt,
667 Default: variable.DefaultValue,
668 Secret: variable.Sensitive,
669 Validate: createVariableValidator(variable),
670 })
671}
672
673func createVariableValidator(variable codersdk.TemplateVersionVariable) func(string) error {
674 return func(s string) error {

Callers 1

Calls 2

PromptFunction · 0.92
createVariableValidatorFunction · 0.85

Tested by

no test coverage detected