from .command import Command
from matador import utils
import subprocess
import os


class DeployTicket(Command):

    def _add_arguments(self, parser):
        parser.prog = 'matador deploy-ticket'
        parser.add_argument(
            '-e', '--environment',
            type=str,
            required=True,
            help='Agresso environment name')

        parser.add_argument(
            '-', '--package',
            type=bool,
            default=False,
            help='Agresso environment name')

    def _checkout_ticket(self, project, ticket, branch='master'):
        repo_folder = utils.matador_repository_folder(project)
        subprocess.run([
            'git', '-C', repo_folder, 'checkout', branch],
            stderr=subprocess.STDOUT,
            stdout=open(os.devnull, 'w'))

    def _execute(self):
        project = utils.project()
        if not self.args.package:
            utils.update_repository(project)
        self._checkout_ticket(project, 'test')

from .command import Command
from matador import utils
import subprocess
import os


class DeployTicket(Command):

    def _add_arguments(self, parser):
        parser.prog = 'matador deploy-ticket'
        parser.add_argument(
            '-e', '--environment',
            type=str,
            required=True,
            help='Agresso environment name')

        parser.add_argument(
            '-t', '--ticket',
            type=str,
            required=True,
            help='Ticket name')

        parser.add_argument(
            '-b', '--branch',
            type=str,
            default='master',
            help='Branch name')

        parser.add_argument(
            '-', '--package',
            type=bool,
            default=False,
            help='Agresso environment name')

    def _checkout_ticket(self, project, ticket, branch='master'):
        repo_folder = utils.matador_repository_folder(project)
        subprocess.run([
            'git', '-C', repo_folder, 'checkout', branch],
            stderr=subprocess.STDOUT,
            stdout=open(os.devnull, 'w'))

    def _execute(self):
        project = utils.project()
        if not self.args.package:
            utils.update_repository(project, self.args.branch)
        self._checkout_ticket(project, self.args.ticket)

Add ticket and branch arguments
Add ticket and branch arguments

  from .command import Command
  from matador import utils
  import subprocess
  import os
  
  
  class DeployTicket(Command):
  
      def _add_arguments(self, parser):
          parser.prog = 'matador deploy-ticket'
          parser.add_argument(
              '-e', '--environment',
              type=str,
              required=True,
              help='Agresso environment name')
  
          parser.add_argument(
+             '-t', '--ticket',
+             type=str,
+             required=True,
+             help='Ticket name')
+ 
+         parser.add_argument(
+             '-b', '--branch',
+             type=str,
+             default='master',
+             help='Branch name')
+ 
+         parser.add_argument(
              '-', '--package',
              type=bool,
              default=False,
              help='Agresso environment name')
  
      def _checkout_ticket(self, project, ticket, branch='master'):
          repo_folder = utils.matador_repository_folder(project)
          subprocess.run([
              'git', '-C', repo_folder, 'checkout', branch],
              stderr=subprocess.STDOUT,
              stdout=open(os.devnull, 'w'))
  
      def _execute(self):
          project = utils.project()
          if not self.args.package:
-             utils.update_repository(project)
+             utils.update_repository(project, self.args.branch)
-         self._checkout_ticket(project, 'test')
+         self._checkout_ticket(project, self.args.ticket)
  
Add ticket and branch arguments
## Code Before:
from .command import Command
from matador import utils
import subprocess
import os


class DeployTicket(Command):

    def _add_arguments(self, parser):
        parser.prog = 'matador deploy-ticket'
        parser.add_argument(
            '-e', '--environment',
            type=str,
            required=True,
            help='Agresso environment name')

        parser.add_argument(
            '-', '--package',
            type=bool,
            default=False,
            help='Agresso environment name')

    def _checkout_ticket(self, project, ticket, branch='master'):
        repo_folder = utils.matador_repository_folder(project)
        subprocess.run([
            'git', '-C', repo_folder, 'checkout', branch],
            stderr=subprocess.STDOUT,
            stdout=open(os.devnull, 'w'))

    def _execute(self):
        project = utils.project()
        if not self.args.package:
            utils.update_repository(project)
        self._checkout_ticket(project, 'test')

## Instruction:
Add ticket and branch arguments
## Code After:
from .command import Command
from matador import utils
import subprocess
import os


class DeployTicket(Command):

    def _add_arguments(self, parser):
        parser.prog = 'matador deploy-ticket'
        parser.add_argument(
            '-e', '--environment',
            type=str,
            required=True,
            help='Agresso environment name')

        parser.add_argument(
            '-t', '--ticket',
            type=str,
            required=True,
            help='Ticket name')

        parser.add_argument(
            '-b', '--branch',
            type=str,
            default='master',
            help='Branch name')

        parser.add_argument(
            '-', '--package',
            type=bool,
            default=False,
            help='Agresso environment name')

    def _checkout_ticket(self, project, ticket, branch='master'):
        repo_folder = utils.matador_repository_folder(project)
        subprocess.run([
            'git', '-C', repo_folder, 'checkout', branch],
            stderr=subprocess.STDOUT,
            stdout=open(os.devnull, 'w'))

    def _execute(self):
        project = utils.project()
        if not self.args.package:
            utils.update_repository(project, self.args.branch)
        self._checkout_ticket(project, self.args.ticket)
