Command-Line Parsing
Guardian Tcl supports command-line parsing with Usage, a suite for parsing
command line arguments and generating documentation from a spec that can be
embedded as #USAGE comments in the top of a script file.
When run with the -U or --usage flag and a script, guarsh will use Usage
to parse the script’s command-line arguments and store the results of this parse
in the usage Tcl array. This is equivalent to the parsing done with usage bash, usage exec, or similar, with a few differences:
- The results of parsing the arguments are stored in a Tcl array1 named
usageinstead of environment variables. - Repeated arguments are stored as Tcl lists instead of shell-quoted strings.
- Boolean and count flags are always set in the array, with a value of 0 if they do not appear.
-
Actually a dictionary in the
usagevariable, but in Jim Tcl arrays and dict variables are the same thing. ↩