'use strict';

const Generator = require('yeoman-generator');
const Batangularjs = require('../core');

module.exports = class extends Generator {
  constructor(args, opts) {
    super(args, opts);

    this.args = args;
    this.opts = opts;
  }

  validateArgs() {
    if (!this.args.length) {
      this.env.error('Sintax error, you must use the sintax: batangularjs:module <module> [-r][-c]');
      return;
    }
    this.modulePath = this.args[0];
    this.moduleName = Batangularjs.upperCaseFirst(
      Batangularjs.namePath(this.modulePath)
    );
    this.optRoute = this.opts.r;
  }

  writing() {
    let data = {
      name: this.moduleName,
      capitalizeName: Batangularjs.upperCaseFirst(this.moduleName),
      route: this.optRoute
    };

    Batangularjs.generateFile(
      Batangularjs.fileDirPath(this.modulePath, 'module', true),
      'module.js',
      data,
      this
    );
  }
};

@@ -387,20 +387,24 @@
 %5B-r%5D%5B-c%5D
+%5B-t%5D
 ');%0A
-
       re
@@ -587,16 +587,89 @@
 opts.r;%0A
+    this.optComponent = this.opts.c;%0A    this.optTemplate = this.opts.t;%0A
   %7D%0A%0A  w
@@ -789,24 +789,106 @@
 oduleName),%0A
+      templateUrl: %60./$%7BBatangularjs.kebabCase(this.moduleName)%7D.component.html%60,%0A
       route:
@@ -1048,22 +1048,721 @@
    this%0A
-
     );
+%0A%0A    this._writeComponent(data);%0A  %7D%0A%0A  _writeComponent(data) %7B%0A    let nameTemplate = 'component.js';%0A    const dirTemplate = '../../component/templates';%0A    if (this.optTemplate) %7B%0A      nameTemplate = 'component-separated.js';%0A      Batangularjs.generateFile(%0A        Batangularjs.fileDirPath(this.modulePath, 'component', true)%0A          .replace('.component.js', '.component.html'),%0A        %60$%7BdirTemplate%7D/component-separated.html%60,%0A        data,%0A        this%0A      );%0A    %7D%0A%0A    if (this.optComponent) %7B%0A      Batangularjs.generateFile(%0A        Batangularjs.fileDirPath(this.modulePath, 'component', true),%0A        %60$%7BdirTemplate%7D/$%7BnameTemplate%7D%60,%0A        data,%0A        this%0A      );%0A    %7D
 %0A  %7D%0A%7D;%0A

Add component params