/*
 * grunt-triton
 * https://github.com/travispaul/grunt-triton
 *
 * Copyright (c) 2016 Travis Paul
 * Licensed under the MIT license.
 */

'use strict';

module.exports = function(grunt) {

  // Please see the Grunt documentation for more information regarding task
  // creation: http://gruntjs.com/creating-tasks

  grunt.registerMultiTask('triton', 'Provision a Triton instance from  your Gruntfile.', function() {
    // Merge task-specific and/or target-specific options with these defaults.
    var options = this.options({
      punctuation: '.',
      separator: ', '
    });

    // Iterate over all specified file groups.
    this.files.forEach(function(f) {
      // Concat specified files.
      var src = f.src.filter(function(filepath) {
        // Warn on and remove invalid source files (if nonull was set).
        if (!grunt.file.exists(filepath)) {
          grunt.log.warn('Source file "' + filepath + '" not found.');
          return false;
        } else {
          return true;
        }
      }).map(function(filepath) {
        // Read file source.
        return grunt.file.read(filepath);
      }).join(grunt.util.normalizelf(options.separator));

      // Handle options.
      src += options.punctuation;

      // Write the destination file.
      grunt.file.write(f.dest, src);

      // Print a success message.
      grunt.log.writeln('File "' + f.dest + '" created.');
    });
  });

};

@@ -530,346 +530,590 @@
 s(%7B%0A
+%0A
       
-punctuation: '.',%0A      separator: ', 
+client: %7B%0A        profileName: 'env
 '%0A    
-%7D);
+  %7D,
 %0A%0A    
+ 
+ 
 // 
-Iterate over all specified file groups.%0A    this.files.forEach(function(f) %7B%0A      // Concat specified files.%0A      var src = f.src.filter(function(filepath) %7B%0A        // Warn on and remove invalid source files (if nonull was set).%0A        if (!grunt.file.exists(filepath))
+passed directly to createMachine%0A      machine: %7B%0A        name: null,%0A        tags: null%0A      %7D,%0A      %0A      // false: waits for instance to be in the 'running' state%0A      // true: completes the task after creating the instance%0A      // ignored when waitFor options are present%0A      async: false,%0A%0A      // when truth and user provides no waitFor options, defaults are used.%0A      waitForHTTP: false,%0A%0A      // waitFor option defaults%0A      waitFor:%7B%0A%0A        // finish the task when HTTP is ready%0A        http:
  %7B%0A
+%0A
     
@@ -1122,68 +1122,84 @@
     
-grunt.log.warn('Source file %22' + filepath + '%22 not found.');
+// false: uses instance's public IP%0A          // true: Use CNS instance FQDN
 %0A   
@@ -1209,21 +1209,23 @@
     
-return
+useCns:
  false
-;
+,%0A
 %0A   
@@ -1233,447 +1233,993 @@
     
-%7D else %7B%0A          return true;%0A        %7D%0A      %7D).map(function(filepath) %7B%0A        // Read file source.%0A        return grunt.file.read(filepath);%0A      %7D).join(grunt.util.normalizelf(options.separator));%0A%0A
+  // http or https%0A          proto: 'http',%0A%0A          // if false, defaults to either 80 or 443 depending on proto%0A          port: 80,%0A%0A          // Type of HTTP request to make%0A          method: 'HEAD',%0A%0A          // expected response status%0A          status: 200,%0A%0A          // check every interval seconds%0A          interval: 1,%0A          %0A          // give up after this many intervals%0A          timeout: 30,%0A          %0A   
       
+ 
 // 
-Handle options.%0A      src += options.punctuation;%0A%0A      // Write the destination file.%0A      grunt.file.write(f.dest, src);%0A%0A      // Print a success message.%0A      grunt.log.writeln('File %22' + f.dest + '%22 created.');%0A    %7D
+show a . for each interval%0A          twiddle: true,%0A%0A        %7D%0A%0A      %7D,%0A     %0A      // Use first package that meets this minimum criteria %0A      // only used if no package uuid set in machine%7B%7D%0A      package: %7B%0A        memory: null,%0A        disk: null,%0A        swap: null,%0A        vcpus: null,%0A        lwps: null%0A%0A      %7D,%0A%0A      // Use first image found that meets this criteria %0A      // only used if no image uuid set in machine%7B%7D%0A      image: %7B%0A        name: null,%0A        os: null,%0A        tags: null%0A      %7D%0A%0A    %7D);%0A    console.log(options
 );%0A 

Add default options