Source

django-envconf / management / commands / startproject.py

Full commit
import os
from django.core.management import call_command
from django.core.management.commands import startproject
from optparse import make_option

from envconf.management import utils

class Command(startproject.Command):
    option_list = startproject.Command.option_list + (
        make_option('--withenvconf',
            action = 'store',
            dest = 'withenvconf',
            default = [],
            nargs = 3,
            help = 'Starts a projects with environments'),
        )

    def handle_label(self, project_name, **options):
        if 'withenvconf' in options:
            self._create_project(project_name)

            for env in options['withenvconf']:
                call_command('startenv', env, directory = '%s/%s/environments/' % (os.getcwd(), project_name))
            call_command('setenv', 'settings', directory = '%s/%s/' % (os.getcwd(), project_name))
        else:
            super(Command, self).handle_label(project_name, options)

    def _create_project(self, project_name):
        directory = os.getcwd()

        utils.copy_helper(self.style, 'project', project_name, directory)