<commit_before>/************
  IO stuff  
 ************/
const fs = require('fs');
const readJSON = require('load-json-file');
const writeJSON = require('write-json-file');

/*************
  CLI stuff  
 *************/
const col = require('cli-color');
const userHome = process.env.HOME || process.env.USERPROFILE;
const file = userHome + '/' + (process.env.USERPROFILE ? '_' : '.') + 'pmc.projects.json';

/********************
  Functional stuff  
 ********************/
const keepDoing = (This, For, nTimes, DoThisAtLast) => nTimes <= 0 ? DoThisAtLast : (For + keepDoing(This, For, nTimes - 1, DoThisAtLast));
const nSpaces = (n) => keepDoing((a, b) => a + b, ' ', n, ''); // Crazy as it sounds, this returns n spaces, functionally

/************
  PRM stuff 
 ************/
var pmc = {};
const Project = require('./Project.class');
const printError = err => console.log(col.white.bgLightRed(err));
const p2s = (p, m) => console.log(col.red(p.name), nSpaces(m - p.name.length), '@', col.yellow.bgBlack(p.location.toLowerCase()));
const usage = 'Usage:\n pmc ls|list\n pmc rm|remove <project-name>\n pmc add <project-name> <location>\n cd $(pmc <project-name>)|`pmc <project-name>';
const projectNotFound = p => { console.log(col.red(p), col.blue('project not found.'), '\n', usage); pmc.ls(); }

pmc.ls = () => readJSON(file)
.then(projects => {
  const maxLen = projects.reduce((max, p) => max = Math.max(max, p.name.length), 0);
  projects
  .sort((p, q) => p.name.length > q.name.length)
  .map(p => p2s(p, maxLen))
})
.catch(printError);

pmc.add = (projectName, location) => readJSON(file)
.then(<commit_msg>add usage for starting project<commit_after>/************
  IO stuff  
 ************/
const fs = require('fs');
const readJSON = require('load-json-file');
const writeJSON = require('write-json-file');

/*************
  CLI stuff  
 *************/
const col = require('cli-color');
const userHome = process.env.HOME || process.env.USERPROFILE;
const file = userHome + '/' + (process.env.USERPROFILE ? '_' : '.') + 'pmc.projects.json';

/********************
  Functional stuff  
 ********************/
const keepDoing = (This, For, nTimes, DoThisAtLast) => nTimes <= 0 ? DoThisAtLast : (For + keepDoing(This, For, nTimes - 1, DoThisAtLast));
const nSpaces = (n) => keepDoing((a, b) => a + b, ' ', n, ''); // Crazy as it sounds, this returns n spaces, functionally

/************
  PRM stuff 
 ************/
var pmc = {};
const Project = require('./Project.class');
const printError = err => console.log(col.white.bgLightRed(err));
const p2s = (p, m) => console.log(col.red(p.name), nSpaces(m - p.name.length), '@', col.yellow.bgBlack(p.location.toLowerCase()));
const usage = 'Usage:\n pmc ls|list\n pmc rm|remove <project-name>\n pmc add <project-name> <location>\n cd $(pmc <project-name>)|`pmc <project-name>\n $(pmc start <project-name>)\n pmc add-start <project-name> "scripts_to_run"';
const projectNotFound = p => { console.log(col.red(p), col.blue('project not found.'), '\n', usage); pmc.ls(); }

pmc.ls = () => readJSON(file)
.then(projects => {
  const maxLen = projects.reduce((max, p) => max = Math.max(max, p.name.length), 0);
  projects
  .sort((p, q) => p.name.length > q.name.length)
  .map(p => p2s(p, maxLen))
})
.catch(printError);

pmc.add = (projectName, location) => readJSON(file)
.then(
{'fraction_non_alphanumeric': 0.25428313796212804, 'fraction_numerical': 0.003005710850616171, 'mean_word_length': 4.446808510638298, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 41, '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': '2778778', 'n_tokens_mistral': 1165, 'n_tokens_neox': 1165, 'n_words': 270}