msi-rs
Rust port of EPICS msi (Macro Substitution and Include) — converts .template files to .db files by expanding macros and processing include/substitute directives.
No EPICS dependencies. Pure text processing.
Output is identical to C msi for ADCore/ADSimDetector templates (verified by golden tests).
CLI
# Build the CLI
# Expand template with macros
# Use substitution file
# With include paths and output file
# Strict mode: fail on undefined macros
Options
| Flag | Description |
|---|---|
-M A=val,B=val |
Macro definitions (comma-separated) |
-S FILE |
Substitution file |
-I DIR |
Include search directory (repeatable) |
-o FILE |
Output file (default: stdout) |
-V |
Strict mode: report undefined macros as errors |
Library API
use Path;
use ;
// Simple: expand template with macros
let output = expand_template?;
// Advanced: use MacHandle directly
let mut mac = new;
mac.install_macros;
let expanded = mac.expand_string;
Macro Syntax
| Syntax | Description |
|---|---|
$(NAME) |
Basic macro reference |
${NAME} |
Brace variant (equivalent) |
$(NAME=default) |
Default value if undefined |
$(NAME,SUB=val) |
Scoped macro definition |
$(A$(B)) |
Nested macro reference |
'$(NAME)' |
Single-quote suppression |
\$(NAME) |
Backslash escape |
Template Directives
include "path/to/file.template"
substitute "A=val,B=val2"
- Include paths are resolved using
-Idirectories - Maximum include depth: 20 (prevents infinite loops)
Substitution File Format
file "template.template" {
# Pattern block: column names + value rows
pattern { P, R }
{ "IOC:", "ai1" }
{ "IOC:", "ai2" }
}
# Global macros apply to all subsequent sets
global { SCAN = "1 second" }
# Regular block: key=value pairs
{ P = "IOC:", R = "ao1" }
Build
License
MIT