Module command line parser: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
Line 6: Line 6:
== Command line parser ==
== Command line parser ==


* options take user input (name or number) and of the style:
* Options take user input (name or number) and of the style:
  '''option='''''answer''
  '''option='''''answer''
* flags are on/off switches and of the style
* flags are on/off switches and of the style
  '''-f'''
  '''-f'''


Run time flags and options can be mixed in any order. Special options to display help and GUI templates should appear on their own.


* the first option= listed by --help may be skiped, for example:
 
* The first option= listed by --help may be skiped, for example:
  d.rast elevation.dem
  d.rast elevation.dem
* 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=.
* 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=.
for example:
for example:
  '''input=''' → '''in='''  and  '''output=''' → '''out='''
  '''input=''' → '''in='''  and  '''output=''' → '''out='''


* flags may be combined behind a single "-". for example:
* Flags may be combined behind a single "-". for example:
  '''-r -f -t'''  is the same as  '''-rtf'''
  '''-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 and --verbose to make modules more noisy.


== GUI window parser ==
== GUI window parser ==

Revision as of 07:22, 18 December 2007

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.


Command line parser

  • Options take user input (name or number) and of the style:
option=answer
  • flags are on/off switches and of the style
-f

Run time flags and options can be mixed in any order. Special options to display help and GUI templates should appear on their own.


  • The first option= listed by --help may be skiped, for example:
d.rast elevation.dem
  • 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=.

for example:

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 and --verbose to make modules more noisy.

GUI window parser

  • 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.

Help page template

  • Auto-created with the --html-description command line option.