<commit_before>#!/usr/bin/env node

var getPixels = require('get-pixels');
var x256 = require('x256');
var minimist = require('minimist');

var pkg = require('./package.json');

function escaped(s) { return '\033[' + [].join.call(arguments, ';') + 'm' }

var BG_CLEAR = escaped(0);
var BG_BOLD = escaped(1);
var NL = '\n';
var PX = '  ';

var args = process.argv.slice(2);
var argv = minimist(args);
var COLS = ~~process.stdout.columns;

var colors = {
    fg: {
        white: fg_256(0xff, 0xff, 0xff)
    },
    bg: {
        red_1: bg_256(0x88, 0x00, 0x00),
        red_2: bg_256(0xaa, 0x00, 0x00),
        red_3: bg_256(0xcc, 0x00, 0x00),
    }
};

function usage() {
    console.log([
        'usage: img-cat [options] [--] [images]',
        '  -h, --help, -?       display this help text',
        '  -v, --version        display version string',
        '  --copyright          display copyright information',
    ].join('\n'));
    process.exit();
}

function version() {
    console.log(pkg.version);
    process.exit();
}

function copyright() {
    console.log([
        'Copyright (c) 2014 <NAME>',
        'MIT license <http://opensource.org/licenses/MIT>',
        'There is NO WARRANTY, to the extent permitted by law.'
    ].join('\n'));
    process.exit();
}

function die(s) {
    // Red gradient along the error message.
    console.error(''
        + BG_BOLD
        + colors.fg.white
        + colors.bg.red_1
        + ' img-cat: '
        + colors.bg.red_2
        + ' error: '
        + colors.bg.red_3
        + ' ' + s + ' '
        + BG_CLEAR<commit_msg>More colorized output<commit_after>#!/usr/bin/env node

var getPixels = require('get-pixels');
var x256 = require('x256');
var minimist = require('minimist');

var pkg = require('./package.json');

function escaped(s) {
    var s = [].join.call(arguments, ';');
    return '\033[' + s + 'm';
}

var BG_CLEAR = escaped(0);
var BG_BOLD = escaped(1);
var NL = '\n';
var PX = '  ';

var args = process.argv.slice(2);
var argv = minimist(args);
var COLS = ~~process.stdout.columns;

var colors = {
    fg: {
        white: fg_256(0xff, 0xff, 0xff)
    },
    bg: {
        green_1: bg_256(0x00, 0x88, 0x00),
        green_2: bg_256(0x00, 0x66, 0x00),

        red_1: bg_256(0x88, 0x00, 0x00),
        red_2: bg_256(0xaa, 0x00, 0x00),
        red_3: bg_256(0xcc, 0x00, 0x00),
    }
};

function box(title, body) {
    function prefix(s, xs) {
        return s + xs.join('\n' + s);
    }

    var pre = BG_BOLD + colors.fg.white;
    var tbg = pre + colors.bg.green_2;
    var bbg = pre + colors.bg.green_1;

    console.log(prefix(tbg, title));
    console.log(prefix(bbg, body));
}

function usage() {
    box([
        ' usage: img-cat [options] [--] [images]               ',
    ], [
        '   -h, --help, -?       display this help text        ',
        '   -v, --version        display version string        ',
        '   --copyright          display copyright information ',
    ]);
    process.exit();
}

function version() {
    console.log(pkg.version);
    process.exit();
}

function copyright() {
    box([
        ' Copyright (c) 2014 <NAME>                         ',
    ], [
        ' MIT license <http://opensource.org/licenses/MIT>      ',
        ' There is NO WARRANTY, to the extent permitted by law. ',
    ]);
    process.exit();
}

function die(s) {
    // Red gradient along the error message.
    console.error(''
        + BG_BOLD
        + colors.fg.white
        + colors.bg.red_1 + ' img-cat: '
        + colors.bg.red_2 + ' error: '
        + colors.bg.red_3 + ' ' + s + ' '
        + BG_CLEAR
{'fraction_non_alphanumeric': 0.1680998613037448, 'fraction_numerical': 0.04105409153952843, 'mean_word_length': 2.0926243567753002, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '3880191', 'n_tokens_mistral': 1383, 'n_tokens_neox': 1286, 'n_words': 292}