<commit_before>var defConfig = require("../config.json");
var colors = require("colors");
var argv = require("./optimist-setup.js").argv;

function Util(config) {
  this.config = config;
}

// Return message correctly formated
Util.prototype.failUp = function() {
  var msg = "  Usage: ".red.bold + argv.$0 + " up <MAC>||<saved item>\n";
  msg += "  " + argv.$0.bold + " up -h".bold + " for more help";
  return msg;
};

// Return message correctly formated
Util.prototype.failAdd = function() {
  var msg = "  Usage: ".red.bold + argv.$0 + " add <name> <MAC>\n";
  msg += "  " + argv.$0.bold + " add -h".bold + " for more help";
  return msg;
};

// Return message correctly formated
Util.prototype.failRm = function() {
  var msg = "  Usage: ".red.bold + argv.$0 + " rm <name>\n";
  msg += "  " + argv.$0.bold + " rm -h".bold + " for more help";
  return msg;
};

// Return messagecorrectly formated
Util.prototype.failEdit = function() {
  var msg = "  Usage: ".red.bold + argv.$0 + " edit <name>\n";
  msg += "  " + argv.$0.bold + " edit -h".bold + " for more help";
  return msg;
};

// Returns true if `mac` is a valid MAC
Util.prototype.checkMac = function(mac) {
  if (mac.length == 17) {
    return new RegExp("([a-fA-f0-9]{2}" + this.config.delimiter + "){5}[a-fA-f0-9]{2}").test(mac);
  }
  if (mac.length != 12 || mac.match(/[^a-fA-F0-9]/)) {
    return false;
  }
  return true;
};

// return the mac in form 'xx:xx:xx:xx:xx:xx'
Util.prototype.beautifyMac = function(mac) {
  if (!this.checkMac(mac)) {
    return false;
  }
  if (mac.length === 17) {
    return mac;
  }
  var newMac = [];
  for (var i = 0; i < mac.length; i += 2) {
    newMac.push(mac.slice(i, i + 2));
  }
  return newMac.join(this.config.delimiter);
};

// return the mac in form 'xxxxxxxxxxxx'
Util.prototype.uglifyMac = function(mac) {
  if (!this.checkMac(mac)) {
    return false;
  }
  mac = mac.toString();
  if (mac.length == 17) {
    mac = mac.replace(new RegExp(mac[2], 'g'), '');
  }
  return mac;
};

// Remove color from colored strings
Util.prototype.decolorize = function(str) {
  return str.replace(/\u001b\[\d+m/g, "");
};

/* istanbul ignore next */
Util.prototype.stdOut = function(data) {
  if (!argv.color) {<commit_msg>set all to uppercase<commit_after>var defConfig = require("../config.json");
var colors = require("colors");
var argv = require("./optimist-setup.js").argv;

function Util(config) {
  this.config = config;
}

// Return message correctly formated
Util.prototype.failUp = function() {
  var msg = "  Usage: ".red.bold + argv.$0 + " up <MAC>||<saved item>\n";
  msg += "  " + argv.$0.bold + " up -h".bold + " for more help";
  return msg;
};

// Return message correctly formated
Util.prototype.failAdd = function() {
  var msg = "  Usage: ".red.bold + argv.$0 + " add <name> <MAC>\n";
  msg += "  " + argv.$0.bold + " add -h".bold + " for more help";
  return msg;
};

// Return message correctly formated
Util.prototype.failRm = function() {
  var msg = "  Usage: ".red.bold + argv.$0 + " rm <name>\n";
  msg += "  " + argv.$0.bold + " rm -h".bold + " for more help";
  return msg;
};

// Return messagecorrectly formated
Util.prototype.failEdit = function() {
  var msg = "  Usage: ".red.bold + argv.$0 + " edit <name>\n";
  msg += "  " + argv.$0.bold + " edit -h".bold + " for more help";
  return msg;
};

// Returns true if `mac` is a valid MAC
Util.prototype.checkMac = function(mac) {
  if (mac.length == 17) {
    return new RegExp("([a-fA-f0-9]{2}" + this.config.delimiter + "){5}[a-fA-f0-9]{2}").test(mac);
  }
  if (mac.length != 12 || mac.match(/[^a-fA-F0-9]/)) {
    return false;
  }
  return true;
};

// return the mac in form 'XX:XX:XX:XX:XX:XX'
Util.prototype.beautifyMac = function(mac) {
  if (!this.checkMac(mac)) {
    return false;
  }
  if (mac.length === 17) {
    return mac.tuUpperCase();
  }
  var newMac = [];
  for (var i = 0; i < mac.length; i += 2) {
    newMac.push(mac.slice(i, i + 2));
  }
  return newMac.join(this.config.delimiter).toUpperCase();
};

// return the mac in form 'xxxxxxxxxxxx'
Util.prototype.uglifyMac = function(mac) {
  if (!this.checkMac(mac)) {
    return false;
  }
  mac = mac.toString();
  if (mac.length == 17) {
    mac = mac.replace(new RegExp(mac[2], 'g'), '');
  }
  return mac.toUpperCase();
};

// Remove color from colored strings
Util.prototype.decolorize = function(str) {
  return str.replace(/\u001b\[\d+m/g, "");
};

/* istanbul ignore next */
Util.prototype.stdOut = function(data) {
  if (!argv.color) {
{'fraction_non_alphanumeric': 0.1997333925794268, 'fraction_numerical': 0.014219062430570984, 'mean_word_length': 3.052205220522052, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '6088048', 'n_tokens_mistral': 1703, 'n_tokens_neox': 1660, 'n_words': 401}