'Parse global arguments, find subcommand from list of subcommand
objects, parse local subcommand arguments and return a tuple of
global options, selected command object, command options, and
command arguments.
Call execute() on the command object to run. The command object has
members \'gopts\' and \'opts\' set for global and command options
respectively, you don\'t need to call execute with those but you could
if you wanted to.'

def parse_subcommands(self, gparser=None):

    gparser = (gparser or self.gparser)
    (gopts, args) = gparser.parse_args()
    if (not args):
        gparser.print_help()
        raise SystemExit('\nError:    you    must    specify    an    action.')
    if gopts.DEBUG:
        console.setLevel(logger.DEBUG)
        config.DEBUG_CONFIG = True
    try:
        cfg = config.StarClusterConfig(gopts.CONFIG)
        cfg.load()
    except exception.ConfigNotFound as e:
        log.error(e.msg)
        e.display_options()
        sys.exit(1)
    except exception.ConfigError as e:
        log.error(e.msg)
        sys.exit(1)
    gopts.CONFIG = cfg
    (subcmdname, subargs) = (args[0], args[1:])
    try:
        sc = self.subcmds_map[subcmdname]
        lparser = optparse.OptionParser(sc.__doc__.strip())
        sc.gopts = gopts
        sc.parser = lparser
        sc.gparser = gparser
        sc.subcmds_map = self.subcmds_map
        sc.addopts(lparser)
        (sc.opts, subsubargs) = lparser.parse_args(subargs)
    except KeyError:
        raise SystemExit(("Error:    invalid    command    '%s'" % subcmdname))
    return (gopts, sc, sc.opts, subsubargs)
