Command-line arguments as a list of strings

$ q test.q -P 0 -abc 123
q).z.x
("-abc";"123")

Note that the script name and the single-letter options used by q itself are not included.

Command-line options can be converted to a dictionary using the convenient .Q.opt function.

$ q -abc 123 -xyz 321
q).Q.opt .z.x
abc| "123"
xyz| "321"

Defaults and types can be provided with .Q.def.

$ q -abc 123 -xyz 321
q).Q.def[`abc`xyz`efg!(1;2.;`a)].Q.opt .z.x
abc| 123
xyz| 321f
efg| `a
q)\\
$ q -abc 123 -xyz 321 -efg foo
q).Q.def[`abc`xyz`efg!(1;2.;`a)].Q.opt .z.x
abc| 123
xyz| 321f
efg| `foo