#!/usr/bin/python

# prints for each GRASS module list of option keys and descriptions

from grass.script import task as gtask
from grass.script.core import get_commands

def get_label(p):
    label = p.get('label')
    if label:
        return label
    return p.get('description')
    
def main():
    print '-' * 80
    for cmd in sorted(get_commands()[0]):
        task = gtask.grassTask(cmd)
        print task.get_name()
        for f in task.get_options()['flags']:
            if len(f.get('name')) > 1: # skip overwrite, ...
                continue
            print '\t' + f.get('name') + ': ' + get_label(f)
        for p in task.get_options()['params']:
            print '\t' + p.get('name') + ': ' + get_label(p)
        print '-' * 80

if __name__ == "__main__":
    main()
