prompt¶
Operation to prompt user for input values.
The input values will be added to a dictionary in the context with a name matching
output_dict_name.
Example¶
The following example uses the prompt operation to get two inputs: First, it prompts
for a name to greet, and then prompts for a greeting message:
examples/operations/prompt.yml¶steps:
"Prompt for name and greetings":
name: prompt
inputs:
- name: "name"
default: "World"
help_text: "Enter whatever name you like"
- name: "greeting"
choices:
- "Hello"
- "Hola"
- "Howdy"
default: "Howdy"
help_text: "How would you like to be greeted"
"Display message":
name: echo
message: |
{{ qwikstart.greeting }}, {{ qwikstart.name }}!
These inputs are then displayed in the terminal using the echo operation. The
prompt for "name" sets a default of "World" and provides a message to help the user
provide an input. Only the name field is required.
The greeting message defines a set of choices which limits the input to predefined
choices for the input. The selection of choices is presented as a numeric input:
Select greeting:
1 - Hello
2 - Hola
3 - Howdy
Choose from 1, 2, 3:
By default, the output for prompt is added to the template_variables namespace, so
output variables can be used for rendering in the echo operation without
explicitly specifying output_namespace (see Common operation configuration).
Required context¶
inputsList of dictionaries describing prompts for user inputs. Each dictionary can have the following keys:
nameThe name of the variable being defined.
defaultOptional default value of variable. Note that this can be defined as a template string, with variables defined in previous prompts or from template variables in the context. For example:
- name: "name" default: "World" - name: "message" default: "Hello {{ qwikstart.name }}!"
help_textOptional info presented to users when responding to prompts.
choicesA list of allowed choices.
choices_fromThe name of a template variable in
template_variablesmapping to a list of allowed choices.
Optional context¶
introductiondefault:
'Please enter the following information:'Message to user before prompting for inputs.
template_variablesDictionary of variables available when rendering the file template.
template_variable_prefixdefault:
'qwikstart'Template variables will be nested in this namespace when rendering; e.g:
{{<template_variable_prefix>.your_template_variable}}
Output¶
This operation can define arbitrary output values based on the values of name defined
in inputs.
Additional notes¶
Overrides default opconfig with:
display_description:Falseoutput_namespace:"template_variables"