protected function generate($type)
    {
        $slug = $this->data['slug'];

        if ($type == 'module') {
            $path = $this->getModulePath($slug);
        } else if ($type == 'theme') {
            $path = $this->getThemePath($slug);
        } else {
            $path = $this->getPackagePath($slug);
        }

        if ($this->files->exists($path)) {
            $this->error('The Package [' .$slug .'] already exists!');

            return false;
        }

        $steps = array(
            'Generating folders...'          => 'generateFolders',
            'Generating files...'            => 'generateFiles',
            'Generating .gitkeep ...'        => 'generateGitkeep',
            'Updating the composer.json ...' => 'updateComposerJson',
        );

        $progress = new ProgressBar($this->output, count($steps));

        $progress->start();

        foreach ($steps as $message => $method) {
            $progress->setMessage($message);

            call_user_func(array($this, $method), $type);

            $progress->advance();
        }

        $progress->finish();

        $this->info("\nGenerating optimized class loader");

        $this->container['composer']->dumpOptimized();

        $this->info("Package generated successfully.");
    }