'Format help on sections for a particular verbosity level.
Args:
level (str): \'short\' or \'long\' (more commands shown for long)'

def format_help_sections(self, level):

    if (level not in levels):
        raise ValueError(('level    must    be    one    of:    %s' % levels))
    add_all_commands(self)
    'Print    help    on    subcommands    in    neatly    formatted    sections.'
    formatter = self._get_formatter()
    if (not hasattr(self, 'actions')):
        self.actions = self._subparsers._actions[(-1)]._get_subactions()
    remaining = set(spack.cmd.commands)
    def add_group(group):
        formatter.start_section(group.title)
        formatter.add_text(group.description)
        formatter.add_arguments(group._group_actions)
        formatter.end_section()
    def add_subcommand_group(title, commands):
        'Add    informational    help    group    for    a    specific    subcommand    set.'
        cmd_set = set(commands)
        cmds = dict(((action.metavar, action) for action in self.actions if (action.metavar in cmd_set)))
        group = argparse._ArgumentGroup(self, title=title)
        for name in commands:
            group._add_action(cmds[name])
            if (name in remaining):
                remaining.remove(name)
        add_group(group)
    show_options = options_by_level[level]
    if (show_options != 'all'):
        opts = dict(((opt.option_strings[0].strip('-'), opt) for opt in self._optionals._group_actions))
        new_actions = [opts[letter] for letter in show_options]
        self._optionals._group_actions = new_actions
    options = ''.join((opt.option_strings[0].strip('-') for opt in self._optionals._group_actions))
    index = index_commands()
    formatter.add_text(('usage:    %s    [-%s]    <command>    [...]' % (self.prog, options)))
    formatter.add_text(self.description)
    formatter.add_text(intro_by_level[level])
    sections = index[level]
    for section in sorted(sections):
        if (section == 'help'):
            continue
        group_description = section_descriptions.get(section, section)
        to_display = sections[section]
        commands = []
        if (section in section_order):
            commands.extend((cmd for cmd in section_order[section] if (cmd in to_display)))
        commands.extend((cmd for cmd in sorted(sections[section]) if (cmd not in commands)))
        add_subcommand_group(group_description, commands)
    add_group(self._optionals)
    formatter.add_text('{help}:\n        spack    help    -a                                        list    all    available    commands\n        spack    help    <command>            help    on    a    specific    command\n        spack    help    --spec                        help    on    the    spec    syntax\n        spack    docs                                                    open    http://spack.rtfd.io/    in    a    browser'.format(help=section_descriptions['help']))
    return formatter.format_help()
