from django.core.management.base import BaseCommand
from optparse import make_option

from django_sonic_screwdriver.git import git


class Command(BaseCommand):

    help = 'Add files to Git repository. Supports all standard "git add ... ".'

    option_list = BaseCommand.option_list + (
        make_option(
            "--dry-run",
            "-n",
            action="store_true",
            dest="dry-run",
            default=False,
            help="Dry run.",
        ),
        make_option(
            "--verbose",
            action="store_true",
            dest="verbose",
            default=False,
            help="Be verbose.",
        ),
        make_option(
            "--interactive",
            "-i",
            action="store_true",
            dest="interactive",
            default=False,
            help="Interactive picking.",
        ),
        make_option(
            "--patch",
            "-p",
            action="store_true",
            dest="patch",
            default=False,
            help="Select hunks interactively.",
        ),
        make_option(
            "--edit",
            "-e",
            action="store_true",
            dest="edit",
            default=False,
            help="Edit current diff and apply.",
        ),
        make_option(
            "--force",
            "-f",
            action="store_true",
            dest="force",
            default=False,
            help="Allow adding otherwise ignored files.",
        ),
        make_option(
            "--update",
            "-u",
            action="store_true",
            dest="update",
            default=False,
            help="Update tracked files.",
        ),
        make_option(
            "--intent-to-add",
            "-N",
            action="store_true",
            dest="intent-to-add",
            default=False,
            help="Record only the fact that the path will be added later.",
        ),
        make_option(
            "--all",
            "-A",
            action="store_true",
            dest="all",
            default=False,
            help="Add changes from all tracked and untracked files.",
        ),
        make_option(
            "--ignore-removal",
            action="store_true",
            dest="ignore-removal",
            default=False,
            help="Ignore paths removed in the working tree (same as --no-all).",
        ),
        make_option(
            "--refresh",
            action="store_true",
            dest="--refresh",
            default=False,
            help="Do not add, only refresh the index.",
        ),
        make_option(
            "--ignore-errors",
            action="store_true",
            dest="--ignore-errors",
            default=False,
            help="Just skip files which cannot be added because of errors.",
        ),
        make_option(
            "--ignore-missing",
            action="store_true",
            dest="--ignore-missing",
            default=False,
            help="Check if - even missing - files are ignored in dry run.",
        ),
    )

    def handle(self, *args, **options):
        arguments = []

        for key in options:
            if options[key]:
                arguments.append("--" + key)

        # Remove --verbosity
        arguments.remove("--verbosity")

        # Add the files
        git.add(arguments)

@@ -48,41 +48,8 @@
 mand
-%0Afrom optparse import make_option
 %0A%0Afr
@@ -211,69 +211,68 @@
     
-option_list = BaseCommand.option_list + (%0A        make_option
+def add_arguments(self, parser):%0A        parser.add_argument
 (%0A  
@@ -430,33 +430,32 @@
 run.%22,%0A        )
-,
 %0A        make_op
@@ -443,35 +443,43 @@
   )%0A        
-make_option
+parser.add_argument
 (%0A          
@@ -614,33 +614,32 @@
 ose.%22,%0A        )
-,
 %0A        make_op
@@ -627,35 +627,43 @@
   )%0A        
-make_option
+parser.add_argument
 (%0A          
@@ -833,33 +833,32 @@
 ing.%22,%0A        )
-,
 %0A        make_op
@@ -846,35 +846,43 @@
   )%0A        
-make_option
+parser.add_argument
 (%0A          
@@ -1047,33 +1047,32 @@
 ely.%22,%0A        )
-,
 %0A        make_op
@@ -1060,35 +1060,43 @@
   )%0A        
-make_option
+parser.add_argument
 (%0A          
@@ -1260,33 +1260,32 @@
 ply.%22,%0A        )
-,
 %0A        make_op
@@ -1273,35 +1273,43 @@
   )%0A        
-make_option
+parser.add_argument
 (%0A          
@@ -1484,33 +1484,32 @@
 les.%22,%0A        )
-,
 %0A        make_op
@@ -1497,35 +1497,43 @@
   )%0A        
-make_option
+parser.add_argument
 (%0A          
@@ -1694,33 +1694,32 @@
 les.%22,%0A        )
-,
 %0A        make_op
@@ -1707,35 +1707,43 @@
   )%0A        
-make_option
+parser.add_argument
 (%0A          
@@ -1952,33 +1952,32 @@
 ter.%22,%0A        )
-,
 %0A        make_op
@@ -1965,35 +1965,43 @@
   )%0A        
-make_option
+parser.add_argument
 (%0A          
@@ -2184,33 +2184,32 @@
 les.%22,%0A        )
-,
 %0A        make_op
@@ -2197,35 +2197,43 @@
   )%0A        
-make_option
+parser.add_argument
 (%0A          
@@ -2431,33 +2431,32 @@
 ll).%22,%0A        )
-,
 %0A        make_op
@@ -2444,35 +2444,43 @@
   )%0A        
-make_option
+parser.add_argument
 (%0A          
@@ -2641,33 +2641,32 @@
 dex.%22,%0A        )
-,
 %0A        make_op
@@ -2654,35 +2654,43 @@
   )%0A        
-make_option
+parser.add_argument
 (%0A          
@@ -2888,25 +2888,24 @@
 %22,%0A        )
-,
 %0A        mak
@@ -2905,19 +2905,27 @@
     
-make_option
+parser.add_argument
 (%0A  
@@ -3119,32 +3119,32 @@
 d in dry run.%22,%0A
+
         ),%0A    )
@@ -3140,15 +3140,8 @@
    )
-,%0A    )
 %0A%0A  

Remove make_option