⚙️ Mold Defaults
A mold script can embed default CLI options via # fimod: comment directives. This makes scripts self-describing — callers don't need to remember which format or options a script expects.
Where to put directives
Directives must appear at the very top of the file, before any code.
# fimod: input-format=csv, output-format=json
# fimod: csv-delimiter=;
def transform(data, args, env, headers):
return [{"name": row["name"], "age": int(row["age"])} for row in data]
Running this with just fimod s -i data.csv -m script.py automatically uses ; as the delimiter.
📋 Supported directives
| Directive | Type | Description |
|---|---|---|
input-format=<fmt> |
value | Input format (json, ndjson, yaml, toml, csv, txt, lines) |
output-format=<fmt> |
value | Output format |
csv-delimiter=<char> |
value | CSV input delimiter character |
csv-output-delimiter=<char> |
value | CSV output delimiter character |
csv-header=<cols> |
value | Explicit column names (comma-separated) |
csv-no-input-header |
flag | Input has no header row |
csv-no-output-header |
flag | Don't write header in output |
no-follow |
flag | Don't follow HTTP redirects |
arg=<name> [desc] |
value | Document an --arg parameter (name + optional description) |
env=<VAR> [desc] |
value | Document an --env variable (name + optional description) |
📏 Priority and parsing rules
CLI wins by default
Explicit CLI arguments always override mold defaults declared with =.
- Directives are read from the top of the file — scanning stops at the first non-comment, non-blank line
- Multiple key-value pairs can appear on the same
# fimod:line, comma-separated - Unknown keys are silently ignored
- Directives in
-einline expressions are never parsed
🔒 Forced directives (!=)
Use != instead of = to declare a directive as forced — the CLI cannot override it.
# The mold forces YAML regardless of what the caller passes
fimod s -i data.json -m strict.py --output-format json
# → output is YAML, not JSON
This is useful for molds that produce a format incompatible with others (e.g., a mold that always emits YAML for a downstream tool).
Debug info
Run with --debug to see which directives are forced:
Forced and default directives can be mixed on the same mold:
Here input-format is locked to csv; output-format is a suggestion that the CLI can override.
💡 Complete example
# fimod: input-format!=csv
# fimod: output-format=json
# fimod: csv-delimiter=;
# fimod: csv-no-input-header
def transform(data, args, env, headers):
# data = [{"col0": ..., "col1": ...}, ...]
return [{"name": row["col0"], "value": int(row["col1"])} for row in data]
# ✅ Use defaults — input-format is locked to csv
fimod s -i data.csv -m script.py
# 🔀 Override output format at call time (allowed — it's a default, not forced)
fimod s -i data.csv -m script.py --output-format yaml
# ⚠️ --input-format is ignored — the mold forces csv
fimod s -i data.csv -m script.py --input-format json