Runtime Variables

Runtime variables allow you to override or introduce variables when you execute a Prog command.

Let us take a look at what a regular Prog command execution might look like:

proggy run yourcommand

When you type the above command into your terminal, Proggy will run the command, yourcommand, available in your account.

Let’s say that within this command, we have the following variables set:

Runtime Variables demo setup
Our Runtime Variable demo setup

Here are the variables set in the command that you see above:

Variable name Value
continent europe
country france

If we run the command here, this is the output we will see:

Output without runtime variables
Default output without using Runtime Variables

Given the Display Text directive we used, this is the text you would expect.

The continent is set to
  {{ continent | capitalize }}
and the country is set to
  {{ country | capitalize }}.

However, what if we want to switch out the continent and country variables when we execute the command?

We can do just that by running the Prog command with extra arguments:

proggy run yourcommand continent="north america" country=canada

Given that continent and country are the variable names, we can substitute them by explicitly defining them when we execute the Prog command.

Notice here that when we use Runtime Variables that variable values with spaces in them need to be surrounded by quotation marks. Proggy will automatically remove these quotation marks. If your value itself has quotations, then you can use the \ character to escape them like so:

somevariable="This value has some \"quotations\""

Let’s take a look at what the output looks like now:

Modified output with Runtime variables
Modified output with Runtime variables

Even though we had set the variables in the Assign Variables directive in the step before, Proggy knows to choose your variables that you manually specified when you ran proggy run.

This flexibility allows you to dynamically override any variables already set in the Prog step sequence and introduces the possibility that you can use Proggy in various automation tasks.

To try this yourself, check out official/demo:runtime-variables

How to use Runtime Variables with arrays and key/value pairs

More complicated uses can be achieved by using Runtime Variables to define arrays and key/value pairs.

When used in combination with loops, this creates a powerful combination of options. Let’s take a look at how we might define arrays and key/value pairs using Runtime Variables.

How to use Runtime Variables with Arrays and Loops

Imagine you have an array list set up like so:

Array list setup
Setting up the array with the Assign List directive

To overwrite this array, you can use the variable stepc817f2, which is the step’s prefix.

proggy run yourcommand \
  "stepc817f2=[\"New item 1\", Two, \"Another item, but 3\"]"

Here are a few syntax reminders when using arrays in Runtime Variables:

  • You must enclose your array with square brackets (ie. [one, two, three])
  • If the array item has spaces, you need to enclose them in quotations and escape the quotes

Lastly, if you plan on designing your Prog “For Each” loop to use a Runtime Variable defined array, you must have a designated Assign List directive even it is blank. Your Runtime Variable can then use the step prefix to dynamically inject its values.

To try this yourself, check out official/demo:runtime-variables-array

How to use Runtime Variables with Key/Value Pairs and Loops

Key/Value pairs also follow a similar path as Arrays when it comes to Runtime Variables.

Here is the syntax you need to use:

proggy run yourcommand \
  stepc817f2="[{\"name\": \"Jack\"}, {\"name\": \"Jill\"}]"

To try this yourself, check out official/demo:runtime-variables-kv