Skip to content

cargs.q

Jas edited this page Nov 5, 2019 · 1 revision

Enhanced Command Line Argument Parser

The functions in this namespace provide additional features on top of the built-in .Q.opt functionality. The additional features are:

  1. Support for parameters specified with double dash (e.g. --parameter) by removing the additional dash
  2. All values in returned dictionary are string (10h) with multi-argument values joined with spaces between them

.cargs.get

Provides the additional parsing features for user-specified command line arguments (via .z.x)

> rlwrap $QHOME/l64/q src/require.q -p 12345 -g 1 -multiArg a b c --singleArg abc
...
q) .cargs.get[]
multiArg | "a b c"
singleArg| "abc"

q) type each .cargs.get[]
multiArg | 10
singleArg| 10

.cargs.getWithInternal

Provides the additional parsing features for all command line arguments (via .z.X)

> rlwrap $QHOME/l64/q src/require.q -p 12345 -g 1 -multiArg a b c --singleArg abc
...
q) .cargs.getWithInternal[]
p        | "12345"
g        | ,"1"
multiArg | "a b c"
singleArg| "abc"
Clone this wiki locally