
'use strict';

var fs = require('fs')
  , _find = require('lodash.find')
  , prompt = require('inquirer').prompt
  , stellorc = require('./stellorc')
  , defaults = require('../conf/cli-defaults')();

/**
 * Initialization questions
 */
var props = [{
  name: 'trelloApiKey',
  message: 'Trello API key',
  default: defaults.trelloApiKey
},{
  name: 'trelloToken',
  message: 'Trello auth token',
  default: defaults.trelloToken
},{
  name: 'trelloBoardUrl',
  message: 'Trello board URL',
  default: defaults.trelloBoardUrl
}];

module.exports = function(opts, cb) {
  var finish = function(result) {
    if(opts.dryRun) {
      console.log(JSON.stringify(result, null, ' '));
      process.exit(0);
    }

    var pkg = require('../package.json');

    result.$$stello = {
      version: pkg.version,
      intialized: Date.now()
    };

    stellorc.write(result, cb);
  };

  // opts might just have defaults... only skip prompts for items that still
  // have a default value
  Object.keys(opts).forEach(function(k) {
    if(opts[k] !== defaults[k]) {
      var prop = _find(props, {name: k});
      if(prop) {
        prop.default = opts[k];
      }
    }
  });

  prompt(props, finish);
};

@@ -13,18 +13,18 @@
 ';%0A%0Avar 
-f
 s
+h
  = requi
@@ -27,17 +27,22 @@
 equire('
-f
+shellj
 s')%0A  , 
@@ -839,16 +839,159 @@
     %7D;%0A%0A
+    // Copy template into working directory... should use async api%0A    sh.rm('-rf', 'src');%0A    sh.cp('-r', __dirname + '/../tpl/src', '.');%0A%0A
     stel

Add template to working directory