<commit_before>'use strict';


var Docker = require('dockerode'),
    fs = require('fs');


/*
 * Commands:
 *  - build
 *  - clean
 *  - delete
 *  - start
 *  - stop
 *  - restart
 *  - list containers / list image
 */
module.exports = function(grunt) {

  grunt.initConfig({
    dock: {
      // Apply to All
      options: {
        protocol: 'https',
        host: '192.168.59.103',
        port: '2376',

        ca: fs.readFileSync('/Users/lwcha_troendlj/.boot2docker/certs/boot2docker-vm/ca.pem'),
        cert: fs.readFileSync('/Users/lwcha_troendlj/.boot2docker/certs/boot2docker-vm/cert.pem'),
        key: fs.readFileSync('/Users/lwcha_troendlj/.boot2docker/certs/boot2docker-vm/key.pem')
      },

      // Dev
      dev: {
        options: {
         /* protocol: 'http',
          host: '192.168.59.103',
          port: '2376',*/

          tag: 'altar/dev',
          dockerfile: 'Dockerfile'
        }
      }
    }
  });


  var commands = {
    list:  { handler: require('./lib/list'),  description: 'List images/containers' },
    clean: { handler: require('./lib/clean'), description: 'Clean old images/containers' },
    build: { handler: require('./lib/build'), description: 'Build an image' }
  };

  /**
   * List / Clean Grunt Task.
   * 
   * Usage:
   *   docker:list:image | docker:list:container
   *   docker:clean:image | docker:clean:container
   *   
   */
  ['list', 'clean'].forEach(function(command) {
    grunt.task.registerTask('dock:' + command, commands[command].description, function(arg) {
    
      // Fake the default Grunt this.options
      this.options = function(options) {
        var config = {};
        for (var name in grunt.config.data.docker.options) {
          config[name] = grunt.config.data.docker.options[name];
          if (!config[name]) config[name] = options[name];
        }
        return config;
      };

      var func = commands[command].handler[arg];
      if (!func) {
        grunt.fail.fatal('Command [' + command + ':' + arg + '] not recognized.');
      }

      func.apply(this, [grunt]);
    });
  });


  grunt.registerMultiTask('dock', 'Docker management', function(command, arg) {
   
    grunt.log.writeln(JSON.stringify(commands));

    grunt.log.writeln('command:', command, ', arg:', arg);

    if (!commands[command]) {
      grunt.fail.warn('Command [' + command + '] not recognized.');
      return;
    }

    // Check arg
    if (typeof(commands[command].handler) != 'function') {<commit_msg>fixed options in basic tasks list/clean<commit_after>'use strict';


var Docker = require('dockerode'),
    fs = require('fs');


/*
 * Commands:
 *  - build
 *  - clean
 *  - delete
 *  - start
 *  - stop
 *  - restart
 *  - list containers / list image
 */
module.exports = function(grunt) {

  grunt.initConfig({
    dock: {
      // Apply to All
      options: {
        protocol: 'https',
        host: '192.168.59.103',
        port: '2376',

        ca: fs.readFileSync('/Users/JohannTDL/.boot2docker/certs/boot2docker-vm/ca.pem'),
        cert: fs.readFileSync('/Users/JohannTDL/.boot2docker/certs/boot2docker-vm/cert.pem'),
        key: fs.readFileSync('/Users/JohannTDL/.boot2docker/certs/boot2docker-vm/key.pem')
      },

      // Dev
      dev: {
        options: {
         /* protocol: 'http',
          host: '192.168.59.103',
          port: '2376',*/

          tag: 'altar/dev',
          dockerfile: 'Dockerfile'
        }
      }
    }
  });


  var commands = {
    list:  { handler: require('./lib/list'),  description: 'List images/containers' },
    clean: { handler: require('./lib/clean'), description: 'Clean old images/containers' },
    build: { handler: require('./lib/build'), description: 'Build an image' }
  };

  /**
   * List / Clean Grunt Task.
   * 
   * Usage:
   *   docker:list:image | docker:list:container
   *   docker:clean:image | docker:clean:container
   *   
   */
  ['list', 'clean'].forEach(function(command) {
    grunt.task.registerTask('dock:' + command, commands[command].description, function(arg) {
    
      // Fake the default Grunt this.options
      this.options = function(options) {
        var config = {};
        for (var name in grunt.config.data.dock.options) {
          config[name] = grunt.config.data.dock.options[name];
          if (!config[name]) config[name] = options[name];
        }
        return config;
      };

      var func = commands[command].handler[arg];
      if (!func) {
        grunt.fail.fatal('Command [' + command + ':' + arg + '] not recognized.');
      }

      func.apply(this, [grunt]);
    });
  });


  grunt.registerMultiTask('dock', 'Docker management', function(command, arg) {
   
    grunt.log.writeln(JSON.stringify(commands));

    grunt.log.writeln('command:', command, ', arg:', arg);

    if (!commands[command]) {
      grunt.fail.warn('Command [' + command + '] not recognized.');
      return;
    }

    // Check arg
    if (typeof(commands[command].handler) != 'function') {
{'fraction_non_alphanumeric': 0.16844007227464364, 'fraction_numerical': 0.01445492872917085, 'mean_word_length': 2.3279893119572477, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4766811', 'n_tokens_mistral': 1707, 'n_tokens_neox': 1599, 'n_words': 293}