Module command line parser
GRASS's command line parser is used by just about all modules to check input values, create help pages and GUIs. With the help of the g.parser module your shell or Python scripts can automatically generate help page templates and fully functional GUI windows. (This is a frontend for the G_parser() function in the C API; see the programmer's manual if you are interested in that)
- see the g.parser help page
Command line parser
- Options take user input (name or number) and of the style:
- flags are on/off switches and of the style
- Run time flags and options can be mixed in any order. Special options to display help and GUI templates should appear on their own.
- Options may be tested for correct numerical value and range. For example testing if the numerical answer falls within 0-100 percent.
- Options may be limited to a discrete set of answers. This results in a pulldown menu in the GUI and a strict answer from the command line.
- The first option= listed by --help may be skiped, for example:
- Option names may be shortened up to the point where they collide. Thus shortening option names in a module with color= and column= options would require at minimum colo= and colu=.
input= → in= and output= → out=
- Flags may be combined behind a single "-". for example:
-r -f -t is the same as -rtf
- All modules can take the command line options --ui to force a GUI window, --overwrite to allow/force overwritting of maps and files, --quiet to make modules less noisy, --verbose to make modules more noisy, and --script to generate a shell script wrapper template.
- --quiet, --verbose, and --overwrite may be abbreviated as --q, --v, --o.
- --help or just 'help' by itself on the command line prints concise module command line option help. This help page will also be printed if there was an error parsing the command options.
GUI window parser
- If a module is called with no options or flags specified then a GUI window is launched.
- If a module is called with options and flags specified, but with the --ui flag, then a GUI window is started with those options and flags already populated. (useful for interactive scripts)
- Auto-created from --tcltk or --interface-description (for XML) command line options.
- Options may be grouped into tabs by the parser settings
- Quotes to protect "special characters" from the shell are not needed here. Quotes needed to denote SQL 'strings' are still needed.
Interactive text based UI parser
If the environment variable GRASS_UI_TERM is set to any value, then an interactive question/answer text based UI is launched instead of the graphical UI window.
Help page template
- Auto-created with the --html-description command line option.
Due to technical reasons some modules do not use the standard parser. These include:
- the photo.* modules