<commit_before>#!/usr/bin/env node
'use strict';
exports.command = {
  description: 'list all projects'
};

if (require.main !== module) {
  return;
}

var async = require('async');
var fs = require('fs');
var util = require('../lib/utilities');
var chalk = require('chalk');
var program = require('commander');
var storage = require('../lib/storage.js');

program._name = 'ls';

function list(project, cb) {
  if (typeof project.directory === 'undefined') {
    console.log(chalk.yellow(project.name));
  } else {
    fs.existsSync(util.expand(project.directory)) ? 
      console.log(chalk.green(project.name), chalk.blue.bold(String.fromCharCode(0x2192)), '', chalk.magenta(project.directory)) :
      console.log(chalk.yellow(project.name));
  }
  cb();
}

function cd(projects, cb) {
  async.each(projects, list, function(err){
    if (!err) return cb();
  });
}

storage.setup(function () {
    cd(storage.all(), process.exit);
});<commit_msg>Formatting for ls, add color handling<commit_after>#!/usr/bin/env node

'use strict';

exports.command = {
  description: 'list all projects'
};

if (require.main !== module) {
  return;
}

var async = require('async');
var chalk = require('chalk');
var fs = require('fs');
var storage = require('../lib/storage.js');
var utilities = require('../lib/utilities.js');

var program = utilities.programDefaults('ls');

program.parse(process.argv);
program.handleColor();

function list(project, cb) {
  if (!project.directory) {
    console.log(chalk.yellow(project.name));
  } else {
    if (fs.existsSync(utilities.expand(project.directory))) {
      console.log(chalk.green(project.name),
        chalk.blue.bold(String.fromCharCode(0x2192)),
        chalk.magenta(project.directory));
    } else {
      console.log(chalk.yellow(project.name));
    }
  }

  cb();
}

storage.setup(function () {
  async.each(storage.all(), list, function () {
    process.exit();
  });
});
{'fraction_non_alphanumeric': 0.1868818323789693, 'fraction_numerical': 0.0052056220718375845, 'mean_word_length': 4.098143236074271, 'pattern_counts': {'":': 0, '<': 3, '<?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': '5479025', 'n_tokens_mistral': 649, 'n_tokens_neox': 630, 'n_words': 119}