#!/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 = """Shows an incident

To display more data, see the output template definition with l3t-showrc.
"""

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


Get().main()
