Skip to main content

Module text

Module text 

Source
Expand description

The text script format: a hand-writable, datadriven-style command file.

A script is a sequence of stanzas, each a command and its expected output:

write-single-ts shard=data ts=0 count=5000
----
wrote 5000

count id=1001 ts=5
----
10000

A stanza is a command (a directive line plus an optional indentation-structured body) up to a ---- separator, then the expected output up to a blank line. The ---- block is the assertion; REWRITE=1 regenerates it (see crate::script). A # at column 0 is a comment; an indented #0 is a column reference in MIR. Comments and blank lines are preserved across a rewrite.

Command bodies are indentation-structured: define-schema/write-rows/peek carry rows or columns, and define carries import/build/export sub-commands, with a build’s MIR as its own deeper-indented sub-body.

StructsΒ§

Line πŸ”’
A non-blank line of a command block, with its leading-space indentation.
Stanza
A command stanza: the input block, the expected output, and the parsed command.

EnumsΒ§

Item
One element of a parsed script file, retained so a REWRITE reproduces the file faithfully.

FunctionsΒ§

body_text πŸ”’
Render body lines as text, dedented to the body’s minimum indentation so their relative structure (which MIR depends on) is preserved.
columns_from_body πŸ”’
Parse body lines as column declarations: name type [nullable].
group πŸ”’
Split body lines into (header, body) groups: each header is a line at the minimum indentation, owning the following more-indented lines as its body.
lex πŸ”’
Split a command block into non-blank lines, recording each line’s indentation.
opt_string πŸ”’
opt_u64 πŸ”’
opt_usize πŸ”’
parse_command πŸ”’
Parse one command block (directive line plus indentation-structured body).
parse_create_dataflow πŸ”’
Parse a create-dataflow body of import/build/export sub-commands. The directive’s bare flags carry the dataflow-level options (optimize).
parse_export πŸ”’
Parse an export sub-command into an ExportSpec. The kind= argument selects the variant (defaulting to index); each kind takes its own arguments.
parse_file
Parse a script file into items: each command stanza plus the comments and blank lines around it.
parse_header πŸ”’
Parse a header line into its verb, key=value arguments, and bare flags.
parse_usize_list πŸ”’
Parse a [a,b,c] list of usizes ([] is empty).
req πŸ”’
req_u64 πŸ”’
rewrite
Reproduce a script file with each stanza’s expected output replaced by its actual output, for REWRITE. actuals has one entry per Item::Stanza, in order.
rows_from_body πŸ”’
Parse body lines as rows of raw space-separated value tokens (quotes intact). The tokens are typed against the schema server-side; see cell_from_token.
settings_from_body πŸ”’
Parse body lines as dyncfg settings: name type value.
tokenize πŸ”’
Split a header line into whitespace-separated tokens, keeping "..." strings and [...] lists intact.