<commit_before>#!/usr/bin/env node
'use strict';

const config = require('./../../../config');
const miteApi = require('./../../mite-api')(config.get());

const formater = require('./../../formater');

/**
 * https://www.npmjs.com/package/tabtab#3-parsing-env
 *
 * @param {string} env.lastPartial - the characters entered in the current
 *                               argument before hitting tabtab
 * @param {string} env.prev - last given argument value, or previously
 *                            completed value
 * @param {string} env.words - the number of argument currently active
 * @param {string} env.line - the current complete input line in the cli
 * @returns {Promise<Array<string>>}
 */
module.exports = async ({ words }) => {

  switch(words) {
    case 2: {
      return ['note'];
    }
    // project
    case 3: {
      return miteApi.getProjects({ archived: false }).then(
        projects => projects.map(p => (p.name))
      );
    }
    // service
    case 4: {
      return miteApi.getServices({ archived: false }).then(
        service => service.map(s => ({
          name: s.name,
          description: s.name + (s.billable ? ' $' : '')
        }))
      );
    }
    // minutes
    case 5: {
      const minutes = [1, 5, 15, 30, 45, 60, 90, 120, 150, 180, 210, 240, 300, 360, 420, 480];
      return minutes.map(minutes => ({
        description: String(minutes) + ' minute(s)',
        name: formater.minutesToDuration(minutes),
      }));
    }
    // date
    case 6: {
      return [
        (new Date()).toISOString().substr(0, 10)
      ];
    }
  }
};
<commit_msg>refactor: new completion to have fever returns<commit_after>#!/usr/bin/env node
'use strict';

const config = require('./../../../config');
const miteApi = require('./../../mite-api')(config.get());

const formater = require('./../../formater');

/**
 * https://www.npmjs.com/package/tabtab#3-parsing-env
 *
 * @param {string} env.lastPartial - the characters entered in the current
 *                               argument before hitting tabtab
 * @param {string} env.prev - last given argument value, or previously
 *                            completed value
 * @param {string} env.words - the number of argument currently active
 * @param {string} env.line - the current complete input line in the cli
 * @returns {Promise<Array<string>>}
 */
module.exports = async ({ words }) => {

  let options = [];
  switch(words) {
    case 2: {
      options.push(['note']);
      break;
    }
    // project
    case 3: {
      const projects = await miteApi.getProjects({ archived: false });
      options.push(...projects.map(p => (p.name)));
      break;
    }
    // service
    case 4: {
      const services = await miteApi.getServices({ archived: false });
      options.push(...services.map(s => (
        {
          name: s.name,
          description: s.name + (s.billable ? ' $' : '')
        }
      )));
      break;
    }
    // minutes
    case 5: {
      // add one option for each time interval which should be most common
      const minutes = [1, 5, 15, 30, 45, 60, 90, 120, 150, 180, 210, 240, 300, 360, 420, 480];
      options.push(...minutes.map(minutes => ({
        description: `${minutes} minute(s)`,
        name: formater.minutesToDuration(minutes),
      })));
      break;
    }
    // date
    case 6: {
      options.push([
        // add YYYY-MM-DD as option
        (new Date()).toISOString().substr(0, 10)
      ]);
      break;
    }
  }

  return options;
};

{'fraction_non_alphanumeric': 0.1649514008004574, 'fraction_numerical': 0.0274442538593482, 'mean_word_length': 2.0585664335664338, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3620600', 'n_tokens_mistral': 1154, 'n_tokens_neox': 1044, 'n_words': 287}