#!/usr/bin/python3 -s
import shlex
import subprocess
from l3tlib.command import L3tIncidentCommand
from l3tlib.template import format


class Open(L3tIncidentCommand):

    descr = "Opens an incident using xdg-open"

    def run(self):
        incident = self.l3t.get_incident(self.opts.incident, self.opts.bug)
        raw_cmd = format(self.config.l3t.incident_open_command,
                         incident=incident.id)
        args = shlex.split(raw_cmd)
        subprocess.call(args)


Open().main()
