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:
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¶
inputs
List of dictionaries describing prompts for user inputs. Each dictionary can have the following keys:
name
The name of the variable being defined.
default
Optional 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_text
Optional info presented to users when responding to prompts.
choices
A list of allowed choices.
choices_from
The name of a template variable in
template_variables
mapping to a list of allowed choices.
Optional context¶
introduction
default:
'Please enter the following information:'
Message to user before prompting for inputs.
template_variables
Dictionary of variables available when rendering the file template.
template_variable_prefix
default:
'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
:False
output_namespace
:"template_variables"