VariableInvocationParameter

API: Internal/Beta

An InvocationParameter which produces value(s) from parameters.

data class VariableInvocationParameter(
    val variableNames: List<String>,
    val prefixGlobal: String?,
    val suffixGlobal: String?,
    val prefixVariable: String?,
    val suffixVariable: String?,
    val isPrefixVariablePartOfArg: Boolean?,
    val isSuffixVariablePartOfArg: Boolean?,
    val type: String /* "var" */,
)

The parameter receives a list of variableNames. Each must reference an ApplicationParameter. It is valid to reference both optional and mandatory parameters. This invocation will produce zero values if all the parameters have no value. This is regardless of the prefixes and suffixes.

The invocation accepts prefixes and suffixes. These will alter the values produced. The global affixes always produce one value each, if supplied. The variable specific affixes produce their own value if isXVariablePartOfArg.

Example: Simple variable

VariableInvocationParameter:

{
    "variableNames": ["myVariable"]
}

Values (AppParameterValue):

{
    "myVariable": { "type": "text", "value": "Hello, World!" }
}

Expands to:

"Hello, World!"

Example: Global prefix (command line flags)

VariableInvocationParameter:

{
    "variableNames": ["myVariable"],
    "prefixGlobal": "--count"
}

Values (AppParameterValue):

{
    "myVariable": { "type": "integer", "value": 42 }
}

Expands to:

"--count" "42"

Example: Multiple variables

VariableInvocationParameter:

{
    "variableNames": ["myVariable", "mySecondVariable"],
    "prefixGlobal": "--count"
}

Values (AppParameterValue):

{
    "myVariable": { "type": "integer", "value": 42 },
    "mySecondVariable": { "type": "integer", "value": 120 },
}

Expands to:

"--count" "42" "120"

Example: Variable prefixes and suffixes

VariableInvocationParameter:

{
    "variableNames": ["myVariable"],
    "prefixGlobal": "--entries",
    "prefixVariable": "--entry",
    "suffixVariable": "--next",
    "isPrefixVariablePartOfArg": true,
    "isSuffixVariablePartOfArg": false
}

Values (AppParameterValue):

{
    "myVariable": { "type": "integer", "value": 42 },
}

Expands to:

"--entries" "--entry42" "--next"

Example: Complete example

VariableInvocationParameter:

{
    "variableNames": ["myVariable", "mySecondVariable"],
    "prefixGlobal": "--entries",
    "prefixVariable": "--entry",
    "suffixVariable": "--next",
    "suffixGlobal": "--endOfEntries",
    "isPrefixVariablePartOfArg": false,
    "isSuffixVariablePartOfArg": true
}

Values (AppParameterValue):

{
    "myVariable": { "type": "integer", "value": 42 },
    "mySecondVariable": { "type": "text", "value": "hello" },
}

Expands to:

"--entries" "--entry" "42--next" "--entry" "hello--next" "--endOfEntries"
Properties
variableNames: List<String>
prefixGlobal: String?
suffixGlobal: String?
prefixVariable: String?
suffixVariable: String?
isPrefixVariablePartOfArg: Boolean?
isSuffixVariablePartOfArg: Boolean?
type: String /* "var" */ The type discriminator

API: Stable