if-greater
if-greater - check if left value is greater than right value
SYNOPSIS
Section titled “SYNOPSIS”state-name: tool: if-greater arguments: left: <number1> right: <number2> goto: true: <greater-state> false: <not-greater-state>DESCRIPTION
Section titled “DESCRIPTION”The if-greater tool performs a numeric comparison and returns "true" if the left value is greater than the right value, or "false" otherwise.
Both values are parsed as decimal numbers. The tool returns exit code 1 if either value cannot be parsed as a valid number.
ARGUMENTS
Section titled “ARGUMENTS”| Argument | Required | Default | Description |
|---|---|---|---|
left | Yes | - | The number to compare (left side) |
right | Yes | - | The number to compare against (right side) |
EXIT CODES
Section titled “EXIT CODES”| Code | Meaning |
|---|---|
0 | Success (outputs “true” or “false”) |
1 | Missing argument or invalid number |
OUTPUT
Section titled “OUTPUT”The tool outputs "true" if left > right, or "false" otherwise.
NUMBER PARSING
Section titled “NUMBER PARSING”The tool accepts:
- Integers:
42,-10,0 - Decimals:
3.14,-0.5,100.00 - Scientific notation:
1.5e10,2E-3 - Whitespace-trimmed values
Invalid values that cause exit code 1:
- Non-numeric strings:
"abc","ten" - Special values:
NaN,Infinity - Empty strings or null
EXAMPLES
Section titled “EXAMPLES”Threshold Check
Section titled “Threshold Check”check-threshold: tool: if-greater arguments: left: "{{ error_count }}" right: "10" goto: true: too-many-errors false: acceptable-errorsCompare Metrics
Section titled “Compare Metrics”compare-performance: tool: if-greater arguments: left: "{{ new_latency }}" right: "{{ baseline_latency }}" goto: true: performance-degraded false: performance-okBudget Check
Section titled “Budget Check”check-cost: tool: if-greater arguments: left: "{{ estimated_cost }}" right: "{{ budget_limit }}" goto: true: over-budget false: within-budgetRetry Logic
Section titled “Retry Logic”check-retries: tool: if-greater arguments: left: "{{ retry_count }}" right: "3" goto: true: max-retries-exceeded false: can-retryCOMMON PATTERNS
Section titled “COMMON PATTERNS”Percentage Threshold
Section titled “Percentage Threshold”get-coverage: tool: bash arguments: command: ./coverage.sh | grep -o '[0-9.]*' output: var(coverage) next: check-coverage
check-coverage: tool: if-greater arguments: left: "{{ coverage }}" right: "80" goto: true: coverage-sufficient false: coverage-too-lowAge Check
Section titled “Age Check”check-age: tool: bash arguments: command: 'echo $(( ($(date +%s) - $(stat -f %m file.txt)) / 86400 ))' output: var(age_days) next: is-stale
is-stale: tool: if-greater arguments: left: "{{ age_days }}" right: "7" goto: true: refresh-needed false: still-freshERROR HANDLING
Section titled “ERROR HANDLING”Handle non-numeric values:
check-value: tool: if-greater arguments: left: "{{ possibly_invalid }}" right: "100" goto: true: above-threshold false: below-threshold on-error: 1: invalid-number-errorSEE ALSO
Section titled “SEE ALSO”- if-less - Less than comparison
- if-greater-equal - Greater than or equal
- if-less-equal - Less than or equal
- if-equal - String equality