Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Reference

This reference provides a overview of all CLI/test syntax elements organized by category.

Command Execution

CommandDescriptionLocation
$ <command> …Execute a shell command and match its outputBasic Usage
%EXIT <n>Expect command to exit with specific code nBasic Usage
%EXIT failExpect command to exit with any non-zero codeBasic Usage
%EXIT anyAccept any exit code (including timeouts)Basic Usage
%EXIT timeoutExpect command to timeoutAdvanced Features
%TIMEOUT <duration>Set timeout for a command (e.g., 100ms, 5s)Advanced Features
%SET <variable>Capture full command output into a variableEnvironment
%SET <variable> <pattern>Capture grok captures into a variableEnvironment
%EXPECT <alias> <value>Expect a grok capture to match a valueGrok Patterns
%EXPECT_FAILUREExpect pattern matching to failAdvanced Features

Variables and Quoting

clitest uses shell-style variable references and quoting to delimit strings in commands and control structures.

Quote TypeBehaviorLocation
'text'Single quotes - literal value, no expansionControl Structures
"text"Double quotes - literal value with variable expansionControl Structures
\charBackslash escape - preserve literal meaningControl Structures
$VARBasic variable referenceEnvironment
${VAR}Explicit variable referenceEnvironment
$PWDSpecial variable for working directoryEnvironment

Control Structures

StructureDescriptionLocation
# <comment>Ignore this line during test executionControl Structures
include "path/to/script.cli";Include a script into the current scriptControl Structures
if condition { … }Conditionally execute commands or patternsControl Structures
for <var> in <…> { … }Iterate over a list of valuesControl Structures
background { … }Run commands in background (auto-killed on exit)Control Structures
defer { … }Execute cleanup commands after block ends (LIFO order)Control Structures
retry { … }Retry commands until success or timeoutControl Structures
exit script;Exit script early with success statusControl Structures
set <var> <value>;Set environment variable directlyEnvironment
cd <directory>;Change working directoryEnvironment
using tempdir;Create and use temporary directory (auto-deleted)Environment
using new dir <name>;Create new directory for testing (auto-deleted)Environment
using dir <path>;Use existing directory (not deleted)Environment
pattern <NAME> <regex>;Define custom grok patternGrok Patterns

Patterns

PatternDescriptionLocation
! <text>Auto-escaped pattern (literal text matching + grok patterns)Pattern Matching
? <pattern>Raw pattern (regex-style, requires escaping + grok patterns)Pattern Matching
!!!Multi-line auto-escaped pattern blockPattern Matching
???Multi-line raw pattern blockPattern Matching
"""Multi-line literal blockPattern Matching
*Any pattern (matches any number of lines lazily)Pattern Matching
%{PATTERN_NAME}Standard grok patternGrok Patterns
%{PATTERN_NAME=(regex)}Custom grok pattern with regexGrok Patterns
%{PATTERN_NAME:field_name}Named grok pattern with output fieldGrok Patterns
%{PATTERN_NAME:field_name=(regex)}Custom named grok patternGrok Patterns
repeat { … }Match pattern multiple timesPattern Matching
choice { … }Match any one of specified patternsPattern Matching
unordered { … }Match patterns in any orderPattern Matching
sequence { … }Match patterns in strict orderPattern Matching
optional { … }Make pattern optional (zero or one match)Pattern Matching
if <condition> { … }Conditionally require patternsPattern Matching
not { … }Negative lookahead patternPattern Matching
ignore { … }Skip/ignore certain output patternsPattern Matching
reject { … }Ensure patterns don't appear in outputPattern Matching

Common Grok Patterns

This is a subset of the grok patterns supported by clitest. See the full list of supported patterns at https://docs.rs/grok/latest/grok/patterns/index.html, including the full base patterns in the grok module: https://docs.rs/grok/latest/grok/patterns/grok/index.html.

PatternDescriptionExample
%{DATA}Matches any text (lazy)Hello, %{DATA}
%{GREEDYDATA}Matches any text (greedy)Hello, %{GREEDYDATA}
%{WORD}Matches word characters[%{WORD}]
%{NUMBER}Matches numeric valuesCount: %{NUMBER}