Standard plugin · import "args"
Command-line arguments
Describe a script’s options once, validate the supplied arguments, and receive the parsed values as a table.
Function
args::parse
args::parse(spec: String, argv: String = "") -> DataFrame
spec declares the accepted options and positionals. Declarations are separated by newlines or semicolons. Each declaration has a name, type, optional arity, optional default, and optional help comment.
import "args";
let parsed = args::parse("
threads (t) : int = 4 # worker count
quiet (q) : flag
input : positional+
");
Specification
Types, aliases, and arity
Use name (alias) for a short option alias. Supported value types are int, int64, float, float64, bool, string, date, and timestamp. Values are validated against their declared type, but returned as strings for the script to cast when it uses them.
| Declaration form | Behavior |
|---|---|
limit (n) : int | One required option value, supplied as --limit VALUE or -n VALUE. |
quiet (q) : bool flag | Boolean flag; when present its value is true. |
tag : string+ | One or more occurrences of the option. |
config : string* | Zero or more occurrences. |
input : string positional | One positional argument; positional+ and positional* allow one-or-more and zero-or-more. |
limit : int? = 10 | Optional option. If absent, its default is used; without a default it emits no result row. |
Append # and a description to document an option in the specification. Unknown options, invalid values, duplicate declarations, missing required inputs, and unexpected positionals are errors.
Result
Read the parsed table
The result schema is fixed: kind, name, index, and value. kind is option, flag, or positional. index is zero-based within a repeated option or positional name. A flag value is the string true or false.
Filter on name to select a value, then cast it to the type your program needs. Optional values that are absent emit no row, so scalar can produce null when the filtered result is empty.
let raw_threads = scalar(parsed[filter name == "threads", select { value }]);
let threads = Int64(raw_threads);
Where arguments come from
When argv is omitted or empty, the plugin reads IBEX_ARGS, with one argument per line. Supplying a non-empty argv string is useful for tests and embedding; separate values with spaces or newlines.
// Run: ibex job.ibex -- --threads 8 input.csv
let test_args = args::parse("threads : int; input : string positional", "--threads 8 input.csv");
Related docs
See the I/O guide for the complete script-argument example and the reference for scalar extraction.