'use strict';

module.exports = function(kbox) {

  kbox.whenAppRegistered(function(app) {

    // Get our push and pull stuff
    var puller = require('./pull.js')(kbox, app);
    var pusher = require('./push.js')(kbox, app);

    // Grab the needed clients
    var Terminus = require('./terminus.js');
    var terminus = new Terminus(kbox, app);

    // Set the integrations pull method.
    kbox.integrations.get('pantheon').setMethod('pull', function(opts) {
      var self = this;
      // Default option handling.
      opts = opts || {};
      opts.files = opts.files || true;
      opts.database = opts.database || true;
			// Pull.
      return kbox.Promise.try(function() {
        // Grab pantheon config so we can mix in interactives
        var config = app.config.pluginconfig.pantheon;
        // Grab pantheon aliases
        return terminus.getSiteAliases()
        // Pull screensho
        .then(function() {
          return puller.pullScreenshot(config.site, config.env);
        })
        // Pull our code
        .then(function() {
          self.update('Pulling code.');
          return puller.pullCode(config.site, config.env);
        })
        // Pull our DB if selected
        .then(function() {
          if (opts.database) {
            self.update('Pulling database.');
            return puller.pullDB(config.site, config.env);
          }
        })
        // Pull our files if selected
        .then(function() {
          if (opts.files) {
            self.update('Pulling files.');
            return puller.pullFiles(config.site, config.env);
          }
        })
        .then(function() {
          self.update('Done pulling.');
        });
      });
    });

    // Set the integrations push method.
    kbox.integrations.get('pantheon').setMethod('push', function(opts) {
      // Save reference for later.
      var self = this;
			// Default options.
      opts = opts || {};
      opts.message = opts.message || 'No commit message given.';
      opts.database = opts.database || false;
      opts.files = opts.files || false;
      // Get plugin.
      var config = app.config.pluginconfig.pantheon;
      // Get site aliases.
      return kbox.Promise.try(function() {
        return terminus.getSiteAliases();
      })
      // Push code.
      .tap(function() {
        self.update('Pushing code.');
        return pusher.pushCode(
          config.site,
          config.env,
          opts.message
        );
      })
      // Push database.
      .tap(function() {
        if (opts.database) {
          self.update('Pushing database.');
          return pusher.pushDB(config.site, config.env);
        }
      })
      // Push files.
      .tap(function() {
        if (opts.files) {
          self.update('Pushing files.');
          return pusher.pushFiles(config.site, config.env);
        }
      })
      // Signal completion.
      .tap(function() {
        self.update('Done pushing.');
      });
    });

  });

};

@@ -571,20 +571,22 @@
 iles %7C%7C 
-true
+'none'
 ;%0A      
@@ -622,17 +622,23 @@
  %7C%7C 
-true;%0A%09%09%09
+'none';%0A%0A      
 // P
@@ -1248,32 +1248,60 @@
 f (opts.database
+ && opts.database !== 'none'
 ) %7B%0A            
@@ -1376,34 +1376,37 @@
 onfig.site, 
-config.env
+opts.database
 );%0A         
@@ -1500,32 +1500,57 @@
   if (opts.files
+ && opts.files !== 'none'
 ) %7B%0A            
@@ -1625,34 +1625,34 @@
 onfig.site, 
-config.env
+opts.files
 );%0A         
@@ -1939,11 +1939,14 @@
 is;%0A
-%09%09%09
+      
 // D
@@ -2086,29 +2086,30 @@
 database %7C%7C 
-false
+'none'
 ;%0A      opts
@@ -2135,13 +2135,14 @@
  %7C%7C 
-false
+'none'
 ;%0A  
@@ -2609,16 +2609,44 @@
 database
+ && opts.database !== 'none'
 ) %7B%0A    
@@ -2725,34 +2725,37 @@
 onfig.site, 
-config.env
+opts.database
 );%0A        %7D
@@ -2831,16 +2831,41 @@
 ts.files
+ && opts.files !== 'none'
 ) %7B%0A    
@@ -2944,34 +2944,34 @@
 onfig.site, 
-config.env
+opts.files
 );%0A        %7D

Change GUI integrations to match up with CLI and new GUI form results