Skip to content

Latest commit

 

History

History
199 lines (134 loc) · 5.13 KB

value.md

File metadata and controls

199 lines (134 loc) · 5.13 KB

Value

A generator input value.

Properties

Property Type Required Enum Default Description
default

The value default.

flag string

The flag name for the value.

help string

Help text describing the value.

if string "true"

Determines whether the value is enabled.

key string

The variable name for the value.

mode string "flag"

Determines how the value can be set.

name string

The display name shown when prompting for the value.

options array

A fixed set of valid options for the value.

prompt string "on-unset"

Determines when a value should prompt for input.

transform string

Optional, comma-separated list of transform rules.

type string "string"

Specifies the data type of a value

validate string

Optional, comma-separated list of validation rules.

default

Type Required Enum Default

The value default. Can refer to other values defined earlier in the list.

Examples:

default: '{{ .OtherValue | underscore }}.txt'

flag

Type Required Enum Default
string

The flag name for the value. Will default to a dash separated form of the key.

Examples:

flag: custom-flag-name

help

Type Required Enum Default
string

Help text describing the value. Shown when prompting and when using the --help flag.

Examples:

help: You should enter a random value.

if

Type Required Enum Default
string "true"

Determines whether the value is enabled. Can refer to other values defined earlier in the list (allows for dynamic prompts).

Examples:

if: '{{ .UseDatabase }}'
if: '{{ eq .Language "python" }}'

key

Type Required Enum Default
string

The variable name for the value. This is how you will refer to the value in template files.

Examples:

key: MyValue

mode

Type Required Enum Default
string "flag"

Determines how the value can be set.

Allowed Values:

  • "arg": Can be set via positional argument OR prompt.
  • "flag": Can be set via flag OR prompt.
  • "hidden": Can only be set via user config.

name

Type Required Enum Default
string

The display name shown when prompting for the value. Will default to a humanized form of the key.

Examples:

name: Custom display name

options

Type Required Enum Default
array

A fixed set of valid options for the value. Will cause the value to be rendered as a single or multi-select when prompted (depending on data type). Attempts to assign a value not in this list will raise a validation error.

Examples:

options:
    - foo
    - bar

prompt

Type Required Enum Default
string "on-unset"

Determines when a value should prompt for input.

Allowed Values:

  • "always": Always prompt.
  • "never": Never prompt.
  • "on-empty": Only when input OR default is blank/zero.
  • "on-unset": Only when not explicitly set via CLI.

transform

Type Required Enum Default
string

Optional, comma-separated list of transform rules.

Examples:

transform: trim,uppercase

type

Type Required Enum Default
string "string"

Specifies the data type of a value.

Allowed Values:

  • "bool": Boolean.
  • "int": Integer.
  • "intSlice": Integer array/slice.
  • "string": String.
  • "stringSlice": String array/slice.

validate

Type Required Enum Default
string

Optional, comma-separated list of validation rules.

Examples:

validate: required,email