<commit_before>var util = require('util');
var console = require('./console');
var process = require('./process');

function usage (commands) {
  console.error('USAGE: heroku COMMAND [--app APP] [command-specific-options]\n');
  if (!commands || commands.length === 0) {
    console.error('No commands found');
  } else {
    console.error('Commands:\n');
    commands.forEach(function (command) {
      console.error(util.format('  heroku %s:%s # %s', command.topic, command.command, command.shortHelp));
    });
  }
}

function findCmd (commands, cmd) {
  if (!cmd) { return null; }
  var c = cmd.split(':');
  return commands.filter(function (command) {
    return command.topic === c[0] && command.command === c[1];
  })[0];
}

function parseArgs (cmd, args) {
  var argTemplates = cmd.args ? cmd.args.slice(0) : [];
  var parsed = {};
  for (var i=0; i<args.length; i++) {
    if (args[i][0] === '-') {
      if (args[i] === '-a' || args[i] === '--app') {
        if (!cmd.needsApp) {
          console.error('Invalid argument. No app is needed');
          return process.exit(1);
        }
        parsed.app = args[i+1];
      } else {
        console.error('TODO: parse flags');
        return process.exit(1);
      }
      i++;
    } else {
      var current = argTemplates.pop();
      if (!current) {
        console.error('Too many arguments');<commit_msg>shift instead of pop (args were out of order)<commit_after>var util = require('util');
var console = require('./console');
var process = require('./process');

function usage (commands) {
  console.error('USAGE: heroku COMMAND [--app APP] [command-specific-options]\n');
  if (!commands || commands.length === 0) {
    console.error('No commands found');
  } else {
    console.error('Commands:\n');
    commands.forEach(function (command) {
      console.error(util.format('  heroku %s:%s # %s', command.topic, command.command, command.shortHelp));
    });
  }
}

function findCmd (commands, cmd) {
  if (!cmd) { return null; }
  var c = cmd.split(':');
  return commands.filter(function (command) {
    return command.topic === c[0] && command.command === c[1];
  })[0];
}

function parseArgs (cmd, args) {
  var argTemplates = cmd.args ? cmd.args.slice(0) : [];
  var parsed = {};
  for (var i=0; i<args.length; i++) {
    if (args[i][0] === '-') {
      if (args[i] === '-a' || args[i] === '--app') {
        if (!cmd.needsApp) {
          console.error('Invalid argument. No app is needed');
          return process.exit(1);
        }
        parsed.app = args[i+1];
      } else {
        console.error('TODO: parse flags');
        return process.exit(1);
      }
      i++;
    } else {
      var current = argTemplates.shift();
      if (!current) {
        console.error('Too many arguments');
{'fraction_non_alphanumeric': 0.1917808219178082, 'fraction_numerical': 0.007209805335255948, 'mean_word_length': 2.8275862068965516, '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': '6006502', 'n_tokens_mistral': 893, 'n_tokens_neox': 885, 'n_words': 219}