#!/usr/bin/python
import textwrap
from l3tlib.command import L3tIncidentCommand
from l3tlib.template import format_objects, make_color_helper


wrapper = textwrap.TextWrapper(replace_whitespace=False)


def w(text):
    return "\n".join("    " + line for line in wrapper.wrap(text))


class Get(L3tIncidentCommand):

    descr = """Displays Support Request information from an incident"""

    def run(self):
        template = self.config.l3t.sr_template
        incident = self.l3t.get_incident(self.opts.incident, self.opts.bug,
                                         status=True, slow=True)
        if incident.support:
            objects = [incident.sr]
            C = make_color_helper(self.config)
            for _, formatted in format_objects(template, objects, w=w, C=C):
                # no new line is needed as cheetah already adds one
                print formatted,


Get().main()
