'use strict';
var util = require('util');
var path = require('path');
var yeoman = require('yeoman-generator');

var foldername = path.basename(process.cwd());

var MageModuleGenerator = module.exports = function MageModuleGenerator(args, options, config) {
  yeoman.generators.Base.apply(this, arguments);

  this.on('end', function () {
    this.installDependencies({ skipInstall: options['skip-install'] });
  });

  this.pkg = JSON.parse(this.readFileAsString(path.join(__dirname, '../package.json')));
};

util.inherits(MageModuleGenerator, yeoman.generators.Base);

MageModuleGenerator.prototype.askFor = function askFor() {
  var cb = this.async();

  // have Yeoman greet the user.
  console.log(this.yeoman);

  var prompts = [{
    name: 'namespace',
    message: 'What is the namespace you want to use?',
    default: 'OpenMagento'
  }, {
    name: 'moduleName',
    message: 'What is the name of the module:',
    default: 'MyModule'
  }, 
  {
    type: 'select',
    name: 'codePool',
    message: 'Which code pool do you want to use?',
    choices: [
      {name: "Local", value: "local"},
      {name: "Community", value: "community"}
    ],
    default: 'community'
  },
  {
    name: 'author',
    message: 'Who is the creator?',
    default: 'Someone'
  }];

  this.prompt(prompts, function (props) {
    this.namespace = props.namespace;
    this.moduleName = props.moduleName;
    this.codePool = props.codePool;
    this.author = props.author;
    cb();
  }.bind(this));
};

MageModuleGenerator.prototype.app = function app() {
    this.mkdir('app');
    this.mkdir('app/etc');
    this.mkdir('app/etc/modules');
    this.mkdir('app/code');
    this.mkdir('app/code/' + this.codePool);
    this.mkdir('app/code/' + this.codePool + '/' + this.namespace);
    this.mkdir('app/code/' + this.codePool + '/' + this.namespace + '/' + this.moduleName);
};

@@ -1180,24 +1180,278 @@
 y'%0A  %7D,%0A  %7B%0A
+    type: 'checkbox',%0A    name: 'elements',%0A    message: 'Which elements should be created?',%0A    choices: %5B%0A      %7Bname: %22Layout File%22, value: 'layout'%7D,%0A      %7Bname: %22Front Controller%22,  value: 'frontController'%7D%0A    %5D,%0A      default: false%0A    %7D,%0A  %7B%0A
     name: 'a
@@ -2113,12 +2113,303 @@
 leName);
+%0A%0A    if (this.elements.length) %7B%0A        if (this.elements.indexOf('frontController') !== -1) %7B%0A        %7D%0A%0A        if (this.elements.indexOf('layout') !== -1) %7B%0A%0A        %7D%0A    %7D%0A    this.template('etc-modules.xml', 'app/etc/modules/' + this.namespace + '_' + this.moduleName + '.xml');%0A    
 %0A%7D;%0A

Copy module config