Using Conditions
What are conditions?
Conditions are used when you want to conditionally execute a directive step in Proggy.
Here’s a quick example: Let’s say you are creating a Proggy command that should only be executed on Linux systems. You can set up a condition whereby the Abort Run directive is executed if the {{os}}
global variable is not equal to Linux.
How do I use conditions?
To use conditions, access the conditions configuration by clicking on the bars and selecting Conditions:
When you click on Conditions, you will see the Conditions Settings popup displayed:
Important: Multiple conditions, when set, are evaluated in the AND context. That is, if you have multiple conditions, then all the conditions must be satisfied in order for the condition evaluation to be true.
For each condition, you must specify three parts:
- The thing you want to compare (eg. Usually some dynamic value using output variables)
- The way you want to compare it (eg. equal to, does not equal to, etc)
- The value which, when compared, would evaluate to true for this condition
What condition settings are there?
There are eleven (11) condition settings you can use to control the flow of your Prog command. See below for a detailed description of each one.
Equal To
For this condition, it is expected that you specify a comparative value and a query value.
Typically, for the comparative value, you would insert a variable (eg. piped.output
), and for the query value you would enter the value that would make this condition true or false.
Proggy evaluates the values as strings. Thus, as long as the two values are equal as strings, the condition is considered to be true.
For example:
Comparative Value & Output | Condition | Query Value | Result |
---|---|---|---|
{{ piped.output }}
Output!
|
Equal To | Output! | true |
{{ os }}
Linux
|
Equal To | Windows | false |
Does Not Equal To
For this condition, it is expected that you specify a comparative value and a query value.
Typically, for the comparative value, you would insert a variable (eg. piped.output
), and for the query value you would enter the value that would make this condition true or false.
Proggy evaluates the values as strings. Thus, as long as the two values are not equal as strings, the condition is considered to be true.
For example:
Comparative Value & Output | Condition | Query Value | Result |
---|---|---|---|
{{ piped.output }}
Output!
|
Does Not Equal To | Output! | false |
{{ os }}
Linux
|
Does Not Equal To | Windows | true |
Greater Than
The Greater Than condition compares the comparative and query values as numerical values. It requires the comparative value to be greater than the queried value for this condition to evaluate to true.
For example:
Comparative Value & Output | Condition | Query Value | Result |
---|---|---|---|
{{ 1 + 1 }}
2
|
Greater Than | 1 | true |
{{ 1 + 1 }}
2
|
Greater Than | 2 | false |
Greater or Equal Than
This condition option is similar to the previous one, but requires that the comparative value is greater than or equal to the queried value.
For example:
Comparative Value & Output | Condition | Query Value | Result |
---|---|---|---|
{{ 1 + 1 }}
2
|
Greater Than Or Equal | 2 | true |
{{ 1 + 1 }}
2
|
Greater Than Or Equal | 3 | false |
Less Than
The Less Than condition compares the comparative and query values as numerical values, and requires that the comparative value is less than the queried value in order for the condition to evaluate as true.
For example:
Comparative Value & Output | Condition | Query Value | Result |
---|---|---|---|
{{ 1 + 1 }}
2
|
Less Than | 3 | true |
{{ 1 + 1 }}
2
|
Less Than | 2 | false |
Less or Equal Than
This condition option is similar to the previous one, but requires that the comparative value is less than or equal to the queried value.
For example:
Comparative Value & Output | Condition | Query Value | Result |
---|---|---|---|
{{ 1 + 1 }}
2
|
Less Than Or Equal | 2 | true |
{{ 1 + 1 }}
2
|
Less Than Or Equal | 3 | false |
Includes
The Includes condition setting evaluates both the comparative and queried values as strings.
For Example:
Comparative Value & Output | Condition | Query Value | Result |
---|---|---|---|
{{ os }}
linux
|
Includes | lin | true |
{{ os }}
linux
|
Includes | windows | false |
Does Not Include
The Does Not Include condition setting is the opposite of the previous one.
For Example:
Comparative Value & Output | Condition | Query Value | Result |
---|---|---|---|
{{ os }}
linux
|
Does Not Include | android | true |
{{ os }}
linux
|
Does Not Include | ux | false |
Exists
The Exists condition setting checks for the presence of a file or a folder on the host system.
For Example:
Comparative Value & Output | Condition | Result |
---|---|---|
/home/user/.bashrc
found
|
Exists | true |
/home/user/missing.txt
not found
|
Exists | false |
Does Not Exist
The Does Not Exist condition setting is similar to the previous one, except the opposite. It checks for the absence of a file or folder.
For Example:
Comparative Value & Output | Condition | Result |
---|---|---|
/home/user/missing.txt
not found
|
Does Not Exist | true |
/home/user/.bashrc
found
|
Does Not Exist | false |
Has Content
For the Has Content condition, Proggy checks whether a readable file has the string content you have specified. You must specify a query value with the string you want to check within the file.
For Example:
Comparative Value & Output | Condition | Query Value | Result |
---|---|---|---|
/home/user/.bashrc
found string “export PATH”
|
Has Content | export PATH | true |
/home/user/.bashrc
not found string “export ARCHFLAGS”
|
Has Content | export ARCHFLAGS | false |
Does Not Have Content
Similar but opposite to the previous one, this condition checks whether the specified file does not have the string specified within it.
For Example:
Comparative Value & Output | Condition | Query Value | Result |
---|---|---|---|
/home/user/.bashrc
not found string “export ARCHFLAGS”
|
Does Not Have Content | export ARCHFLAGS | true |
/home/user/.bashrc
found string “export PATH”
|
Does Not Have Content | export PATH | false |
Is Blank Or Empty
This checks to ensure that the value you enter (typically {{ some_variable }}
) is blank or empty (ie. does not exist).
For Example:
Comparative Value & Output | Condition | Result |
---|---|---|
{{ existent_variable }}
123
|
Is Blank or Empty | false |
{{ non_existent_variable }}
null
|
Is Blank or Empty | true |
Is Not Blank Or Empty
The opposite of the above condition, this checks to ensure that the value you enter (typically {{ some_variable }}
) is not blank or empty.
For Example:
Comparative Value & Output | Condition | Result |
---|---|---|
{{ existent_variable }}
123
|
Is Blank or Empty | true |
{{ non_existent_variable }}
null
|
Is Blank or Empty | false |