from optparse import make_option

from django.core.management.base import BaseCommand, CommandError

from cyder.cydhcp.build.builder import DHCPBuilder



class Command(BaseCommand):
    option_list = BaseCommand.option_list + (
        ### action options ###
        make_option('-p', '--push',
                    dest='push',
                    action='store_true',
                    default=False,
                    help="Check files into vcs and push upstream."),
        ### logging/debug options ###
        make_option('-l', '--log-syslog',
                    dest='log_syslog',
                    action='store_true',
                    help="Log to syslog."),
        make_option('-L', '--no-log-syslog',
                    dest='log_syslog',
                    action='store_false',
                    help="Do not log to syslog."),
        make_option('--debug',
                    dest='debug',
                    action='store_true',
                    default=False,
                    help="Print copious amounts of text."),
        ### miscellaneous ###
        make_option('-C', '--no-sanity-check',
                    dest='sanity_check',
                    action='store_false',
                    default=True,
                    help="Don't run the diff sanity check."),
    )

    def handle(self, *args, **options):
        builder_opts = {}
        for name in ('log_syslog', 'debug'):
            val = options.pop(name)
            if val is not None:  # user specified value
                builder_opts[name] = val
            # else get value from settings

        with DHCPBuilder(**builder_opts) as b:
            b.build()
            if options['push']:
                b.push(sanity_check=options['sanity_check'])

from optparse import make_option

from django.core.management.base import BaseCommand, CommandError

from cyder.cydhcp.build.builder import DHCPBuilder


class Command(BaseCommand):
    option_list = BaseCommand.option_list + (
        ### action options ###
        make_option('-p', '--push',
                    dest='push',
                    action='store_true',
                    default=False,
                    help="Check files into vcs and push upstream."),
        ### logging/debug options ###
        make_option('-l', '--log-syslog',
                    dest='log_syslog',
                    action='store_true',
                    help="Log to syslog."),
        make_option('-L', '--no-log-syslog',
                    dest='log_syslog',
                    action='store_false',
                    help="Do not log to syslog."),
        make_option('--debug',
                    dest='debug',
                    action='store_true',
                    default=False,
                    help="Print copious amounts of text."),
        ### miscellaneous ###
        make_option('-C', '--no-sanity-check',
                    dest='sanity_check',
                    action='store_false',
                    default=True,
                    help="Don't run the diff sanity check."),
    )

    def handle(self, *args, **options):
        builder_opts = {}
        for name in ('log_syslog', 'debug'):
            val = options.pop(name)
            if val is not None:  # user specified value
                builder_opts[name] = val
            # else get value from settings

        with DHCPBuilder(**builder_opts) as b:
            b.build()
            if options['push']:
                b.push(sanity_check=options['sanity_check'])

Fix triple newline