if-equal
if-equal - compare two values for equality
SYNOPSIS
Section titled “SYNOPSIS”state-name: tool: if-equal arguments: left: <value1> right: <value2> goto: true: <equal-state> false: <not-equal-state>DESCRIPTION
Section titled “DESCRIPTION”The if-equal tool performs a case-sensitive string comparison between two values. It returns "true" if the values are equal, or "false" if they differ.
Both values are trimmed of leading/trailing whitespace before comparison. This handles common issues with captured outputs that include trailing newlines.
ARGUMENTS
Section titled “ARGUMENTS”| Argument | Required | Default | Description |
|---|---|---|---|
left | Yes | - | First value to compare |
right | Yes | - | Second value to compare |
EXIT CODES
Section titled “EXIT CODES”| Code | Meaning |
|---|---|
0 | Success (outputs “true” or “false”) |
1 | Missing required argument |
OUTPUT
Section titled “OUTPUT”The tool outputs "true" if the trimmed values are equal, or "false" if they differ.
EXAMPLES
Section titled “EXAMPLES”Compare to Expected Value
Section titled “Compare to Expected Value”check-status: tool: if-equal arguments: left: "{{ status }}" right: "ready" goto: true: proceed false: wait-for-readyCompare Two Variables
Section titled “Compare Two Variables”compare-values: tool: if-equal arguments: left: "{{ old_hash }}" right: "{{ new_hash }}" goto: true: no-changes false: has-changesCheck Environment
Section titled “Check Environment”check-env: tool: if-equal arguments: left: "{{ environment }}" right: "production" goto: true: production-deploy false: staging-deployValidate User Choice
Section titled “Validate User Choice”ask-confirmation: tool: ask-user arguments: question: "Continue with deployment?" options: - "yes" - "no" output: var(confirm) next: check-confirm
check-confirm: tool: if-equal arguments: left: "{{ confirm }}" right: "yes" goto: true: deploy false: cancelCheck Command Exit Status
Section titled “Check Command Exit Status”run-tests: tool: bash arguments: command: npm test && echo "passed" || echo "failed" output: var(test_result) next: check-tests
check-tests: tool: if-equal arguments: left: "{{ test_result }}" right: "passed" goto: true: tests-passed false: tests-failedCOMPARISON BEHAVIOR
Section titled “COMPARISON BEHAVIOR”- Case-sensitive:
"Hello"and"hello"are NOT equal - Whitespace-trimmed:
" value "and"value"ARE equal - Type coercion: Non-string values are converted to strings before comparison
- Null handling: Null values are converted to empty strings
COMMON PATTERNS
Section titled “COMMON PATTERNS”Boolean Check
Section titled “Boolean Check”is-enabled: tool: if-equal arguments: left: "{{ feature_flag }}" right: "true" goto: true: feature-enabled false: feature-disabledHTTP Status Check
Section titled “HTTP Status Check”check-response: tool: bash arguments: command: curl -s -o /dev/null -w "%{http_code}" https://api.example.com/health output: var(status_code) next: verify-status
verify-status: tool: if-equal arguments: left: "{{ status_code }}" right: "200" goto: true: healthy false: unhealthySEE ALSO
Section titled “SEE ALSO”- if-not-equal - Negated version
- if-empty - Check for empty values
- switch - Multi-way branching