<commit_before>var R    = require('ramda');

export class CliController {
  constructor(opts = {}) {
    Object.keys(opts).forEach((key) => {
      if (opts.hasOwnProperty(key)) {
        this[key] = opts[key];
      }
    });
  }

  index() {
    throw new Error("Don't use CliController directly, implemente the index action.");
  }

  run_action(action_name, ...args) {
    if (R.isNil(action_name) || !R.is(Function, this[action_name])) {
      args.unshift(action_name);
      action_name = 'index';
    }
    return this.before_action(action_name, ...args);
  }

  before_action(action_name, ...args) {
    var action_result = this[action_name].apply(this, args);
    return this.after_action(action_name, action_result, ...args);
  }

  after_action(action_name, action_result) {
    return action_result;
  }
}<commit_msg>[Controller] Fixing action_name being inserted into arguments when not needed;<commit_after>var R    = require('ramda');

export class CliController {
  constructor(opts = {}) {
    Object.keys(opts).forEach((key) => {
      if (opts.hasOwnProperty(key)) {
        this[key] = opts[key];
      }
    });
  }

  index() {
    throw new Error("Don't use CliController directly, implemente the index action.");
  }

  run_action(action_name, ...args) {
    if (R.isNil(action_name) || !R.is(Function, this[action_name])) {
      if (!R.is(String, action_name)) {
        args.unshift(action_name);
      }
      action_name = 'index';
    }
    return this.before_action(action_name, ...args);
  }

  before_action(action_name, ...args) {
    var action_result = this[action_name].apply(this, args);
    return this.after_action(action_name, action_result, ...args);
  }

  after_action(action_name, action_result) {
    return action_result;
  }
}
{'fraction_non_alphanumeric': 0.14985915492957746, 'fraction_numerical': 0.0, 'mean_word_length': 3.289855072463768, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7422574', 'n_tokens_mistral': 592, 'n_tokens_neox': 578, 'n_words': 110}