Skip to main content
Version: v4.4.0

Inputs

The configuration files that have the inputs field are:

These inputs collect relevant information to the project's scope of the Template, Plugin, or Task. The inputs are interpreted by the STK CLI during the command's execution to ask the users for this information.

info

Inputs are optional. Each .yaml file can have none or multiple inputs.

Input types

Input types are defined in the type field, see what they are:

TypesValue
textString.
boolBoolean.
intInteger.
passwordThe value in the STK CLI is hidden in the format: ****.
multiselectThe values list, allows you to choose 1 or more values (string).

Check the inputs in a template.yaml file:

name: my-template
description: Describe your template explaining its purpose
types:
- app-template
inputs:
- label: Input Example
type: text
name: example
default: any text
required: true
help: "Inform any text (e.g.: My first text input)"

Required Input Fields

  • name: Name of the input (will be handled later)
  • label: Text that will appear on the terminal asking the user for the input.
  • type:
    • text (string).
    • bol (boolean).
    • int (integer).
    • password (The value in the STK CLI is hidden in the format: ****).
    • multiselect (the values list, allows you to choose 1 or more values) (string).

Inputs with required fields examples

Text Input Type

- label: Type your name
name: name
type: text

Multiselect input

inputs:
- label: choose one or more days
name: days
type: multiselect
items:
- Monday
- Tuesday
- Wednesday
- Thursday
- Friday

Optional Input Fields

  • help: This parameter adds support text visible on the terminal. It is displayed with the --help flag to guide the user in filling in the input. It will not appear next to the input field as a help message, only when the user uses any command with the flag beside it. For example: stk create app --template <stack-name>/<plugin-name> --help
- label: Type your name
name: name
type: text
help: "Inform your firstname (e.g.: John)"
  • default: Value associated with the input if no value is entered.
- label: Type your name
name: name
type: text
default: John
  • required: Boolean to indicate whether a value is optional or not, the value will be false if no value is entered.
- label: Type your name
name: name
type: text
required: true
  • items: List of possible values for the input (used with type text (select) or type multiselect).
- label: Type your name
name: name
type: text
items:
- John
- Bill
info

There is no select type for inputs. If you need this option, use both text and items fields. If you have items to add, choose only one option.

  • pattern: Sets a validation for the input field.
- label: Type your name
name: name
type: text
pattern: [A-Za-z]
  • condition: After receiving a value in the input, a condition is set and a second input will be displayed to the user if the condition is met. If the condition is not met, nothing will happen after the condition input.

    • variable: Name of the variable that will be used to evaluate the condition.
    • operator: Operator used to evaluate the condition. Valid operator values are: ==, !=, >, >=, <, <=, containsAny, containsAll, containsOnly, notContainsAny e notContainsAll.
    caution

    You must use double quotes for the following operators: "==", "!=", ">", ">=", "<", "<=".

    For more details about the operators:
    OperatorDescription
    ==Validates if the values are equal.
    !=Validates if the values are different.
    >Validates if the variable is greater than the value.
    <Validates if the variable is less than the value.
    >=Validates if the variable is greater than or equal to the value.
    <=Validates if the variable is less than or equal to the value.
    containsAnyValidates if the variable of type list contains any of the values contained in value.
    containsAllValidates if the variable of type list contains all the values contained in value.
    containsOnlyValidates if the variable of type list contains all the values contained in value and does not contain other elements.
    • value: Value used for the evaluation.
info

The value of the condition must be the same type as the referenced input.

See a condition in an input example. The user answers which language they want to use. The options are Java and Kotlin, and depending on the language chosen, they can see the available versions.

inputs:
- label: what language do you want to use?
type: text
name: language
items:
- Java
- Kotlin
- label: Which Java version do you want to use?
type: text
name: java_version
items:
- "11"
- "17"
condition:
variable: language
operator: "=="
value: Java
- label: Which Kotlin version do you want to use?
type: text
name: kotlin_version
items:
- 1.6
- 1.7
condition:
variable: language
operator: "=="
value: Kotlin

In the example, the condition determines which list is displayed, it depends on the value of the language input. If the value equals Java, a Java version's list is displayed, if it equals Kotlin, a Kotlin list.

Next Steps

Was this page helpful?