#!/usr/bin/env python
#

"""
gmenu: execute menu operation
"""

import sys

from optparse import OptionParser

try:
    import gterm
except ImportError:
    import graphterm.bin.gterm as gterm

usage = "usage: %prog <menu1> <menu2> ... [on/off]"
parser = OptionParser(usage=usage)

(options, args) = parser.parse_args()

if not args:
    sys.exit(0)

if args[-1].lower() in ("on", "off", "true", "false"):
    value = args[-1].lower() in ("on", "true")
    args = args[:-1]
else:
    value = None

if not args:
    sys.exit(0)

target = "_".join(args)

gterm.menu_op(target, value)
    
