content: 'use strict';
  require('babel/register');
  let to = require('to-case');
  let path = require('path');
  let pluralize = require('pluralize');
  let fs = require('fs');
  let argv = require('minimist')(process.argv.slice(2));
  
  let component = to.lower(argv.c);
  let schemaFile = `${component}.json`;
  let schemaPath = path.join('./models/schemas', schemaFile);
  console.log(schemaPath);
  
  let schemaExists = false;
  try {
      fs.statSync(schemaPath);
      schemaExists = true;
  } catch (err) {
      console.log('There is no schema so creating with empty properties');
  }
  
  let schema = schemaExists ? require('../'+schemaPath) : { properties : {}};
  
  
  let componentName = to.capital(component);
  let appFolder = path.join('./app', 'components');
  
  let propertyBagRead = [];
  let propertyBagWrite = [];
  
  console.log(schema.properties);
  for (var prop in schema.properties) {
      if (schema.properties.hasOwnProperty(prop)) {
          switch (schema.properties[prop].type) {
              case 'string':
                  propertyBagRead.push(`\t\t\t\t<div>{this.props.${prop}}</div>`);
                  propertyBagWrite.push(`<input type="text" value={this.props.${prop}} />`);
                  break;
              case 'integer':
              case 'number': // no break statement in 'case 0:' so this case will run as well
                  propertyBagRead.push(`\t\t\t\t<div>{this.props.${prop}}</div>`);
                  propertyBagWrite.push(`<input type="text" value={this.props.${prop}} />`);
                  break; // it encounters this break so will not continue into 'case 2:'
              case 'boolean':
                  propertyBagRead.push(`\t\t\t\t<div>{this.props.${prop}}</div>`);
                  propertyBagWrite.push(`<input type="text" value={this.props.${prop}} />`);
                  break;
              case 'objectId':
                  propertyBagRead.push(`\t\t\t\t<div><a href="#" onClick={this.onViewDetails}>View Details</a></div>`);
                  propertyBagWrite.push(`<input type="hidden" value={this.props.${prop}} />`);
                  break;
              default:
                  console.log('default');
          }
      } 
  }
  let props = propertyBagRead.join('\n').replace(/\t/gi, '    ');
  let reactComponent = `import React from 'react';
  
  export default class ${componentName} extends React.Component {
      constructor(props) {
          super(props);
      }
      render() {
          return (
              <div> 
  ${props} 
              </div>
              );
      }
  }`;
  let pluralComponent = pluralize(component);
  
  let reactComponentList = `import React from 'react';
  import ${componentName} from './${component}';
  export default class ${componentName}List extends React.Component {
      constructor(props) {
          super(props);
      }
      render() {
          let ${component}Nodes = this.state.settings.map((${component}) => {
              return (<${componentName} ${component}={${component}} />);
          });
          return (
              <div> 
                  {${component}Nodes} 
              </div>
              );
      }
  }`;
  //reactComponent
  fs.writeFileSync(path.join(appFolder, component + '.js'), reactComponent);
  fs.writeFileSync(path.join(appFolder, component + '-list.js'), reactComponentList);