<commit_before>#!/usr/bin/env node

/**
 * Jit cat-file
 */
var program = require('commander'),
    fs = require('fs'),
    path = require('path'),
    storage = require('./storage/filesystem'),
    Repo = require('./common/repo'),
    GitObject = require('./common/git_object');

program
  .option('-t', 'show object type')
  .option('-s', 'show object size')
  // TODO
  .option('-e', 'exit with zero when there\'s no error')
  .option('-p', 'pretty-print object\'s content')
  // TODO
  .option('--textconv', 'for blob objects, run textconv on object\'s content')
  // TODO
  .option('--batch', 'show info and content of objects fed from the standard input')
  // TODO
  .option('--batch-check', 'show info about objects fed from the standard input')
  .parse(process.argv);

if(program.args.length < 0) {
  program.help();
}

var repo = new Repo('.git', storage);
repo.init(function(err) {
  repo.read_object({key: program.args[0]}, function(err, object) {
    if(err) {
      console.log(err.message);
    } else {
      if(program.P) {
        console.log(object.content);
      } else if(program.T) {
        console.log(object.type);
      } else if(program.S) {
        console.log(object.size);
      } else {
        program.help();
      }
    }
  });
});<commit_msg>Add utility option --show-index which returns a json representation of current index file<commit_after>#!/usr/bin/env node

/**
 * Jit cat-file
 */
var program = require('commander'),
    fs = require('fs'),
    path = require('path'),
    storage = require('./storage/filesystem'),
    Repo = require('./common/repo'),
    GitObject = require('./common/git_object');

program
  .option('-t', 'show object type')
  .option('-s', 'show object size')
  // TODO
  .option('-e', 'exit with zero when there\'s no error')
  .option('-p', 'pretty-print object\'s content')
  // TODO
  .option('--textconv', 'for blob objects, run textconv on object\'s content')
  // TODO
  .option('--batch', 'show info and content of objects fed from the standard input')
  // TODO
  .option('--batch-check', 'show info about objects fed from the standard input')
  .option('--show-index', 'show info about objects fed from the standard input')
  .parse(process.argv);

if(program.args.length < 0) {
  program.help();
}

// Hack to show index file, for development only
if(program.showIndex) {
  var repo = new Repo('.git', storage);
  repo.init(function(err) {
    repo.read_index(function(err, index) {
      if(err) {
        console.log(err);
      } else {
        console.log(index);
      }
    })
  });
} else {
  var repo = new Repo('.git', storage);
  repo.init(function(err) {
    repo.read_object({key: program.args[0]}, function(err, object) {
      if(err) {
        console.log(err.message);
      } else {
        if(program.P) {
          console.log(object.content);
        } else if(program.T) {
          console.log(object.type);
        } else if(program.S) {
          console.log(object.size);
        } else {
          program.help();
        }
      }
    });
  });
}
{'fraction_non_alphanumeric': 0.17627785058977719, 'fraction_numerical': 0.001310615989515072, 'mean_word_length': 2.6871980676328504, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '467587', 'n_tokens_mistral': 981, 'n_tokens_neox': 973, 'n_words': 244}