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

var Download = require('./');
var input = process.argv.slice(2);
var nopt = require('nopt');
var pkg = require('./package.json');
var progress = require('download-status');
var stdin = require('get-stdin');

/**
 * Options
 */

var opts = nopt({
	extract: Boolean,
	help: Boolean,
	out: String,
	strip: Number,
	version: Boolean
}, {
	e: '--extract',
	h: '--help',
	o: '--out',
	s: '--strip',
	v: '--version'
});

/**
 * Help screen
 */

function help() {
	console.log([
		'',
		'  ' + pkg.description,
		'',
		'  Usage',
		'    download <url>',
		'    download <url> > <file>',
		'    download --out <directory> <url>',
		'    cat <file> | download --out <directory>',
		'',
		'  Example',
		'    download http://foo.com/file.zip',
		'    download http://foo.com/cat.png > dog.png',
		'    download --extract --strip 1 --out dest http://foo.com/file.zip',
		'    cat urls.txt | download --out dest',
		'',
		'  Options',
		'    -e, --extract           Try decompressing the file',
		'    -o, --out               Where to place the downloaded files',
		'    -s, --strip <number>    Strip leading paths from file names on extraction'
	].join('\n'));
}

/**
 * Show help
 */

if (input.indexOf('-h') !== -1 || input.indexOf('--help') !== -1) {
	help();
	return;
}

/**
 * Show package version
 */

if (input.indexOf('-v') !== -1 || input.indexOf('--version') !== -1) {
	console.log(pkg.version);
	return;
}

/**
 * Run
 *
 * @param {Array} src
 * @param {String} dest
 * @api private
 */

function run(src, dest) {
	var download = new Download(opts)
		.use(progress());

	src.forEach(download.get.bind(download));

	if (process.stdout.isTTY) {
		download.dest(dest ? dest : process.cwd());
	}

	download.run(function (err, files) {
		if (err) {
			console.error(err);
			process.exit(1);
		}<commit_msg>Only show progress bar if stdout is a TTY<commit_after>#!/usr/bin/env node
'use strict';

var Download = require('./');
var input = process.argv.slice(2);
var nopt = require('nopt');
var pkg = require('./package.json');
var progress = require('download-status');
var stdin = require('get-stdin');

/**
 * Options
 */

var opts = nopt({
	extract: Boolean,
	help: Boolean,
	out: String,
	strip: Number,
	version: Boolean
}, {
	e: '--extract',
	h: '--help',
	o: '--out',
	s: '--strip',
	v: '--version'
});

/**
 * Help screen
 */

function help() {
	console.log([
		'',
		'  ' + pkg.description,
		'',
		'  Usage',
		'    download <url>',
		'    download <url> > <file>',
		'    download --out <directory> <url>',
		'    cat <file> | download --out <directory>',
		'',
		'  Example',
		'    download http://foo.com/file.zip',
		'    download http://foo.com/cat.png > dog.png',
		'    download --extract --strip 1 --out dest http://foo.com/file.zip',
		'    cat urls.txt | download --out dest',
		'',
		'  Options',
		'    -e, --extract           Try decompressing the file',
		'    -o, --out               Where to place the downloaded files',
		'    -s, --strip <number>    Strip leading paths from file names on extraction'
	].join('\n'));
}

/**
 * Show help
 */

if (input.indexOf('-h') !== -1 || input.indexOf('--help') !== -1) {
	help();
	return;
}

/**
 * Show package version
 */

if (input.indexOf('-v') !== -1 || input.indexOf('--version') !== -1) {
	console.log(pkg.version);
	return;
}

/**
 * Run
 *
 * @param {Array} src
 * @param {String} dest
 * @api private
 */

function run(src, dest) {
	var download = new Download(opts);

	src.forEach(download.get.bind(download));

	if (process.stdout.isTTY) {
		download.use(progress());
		download.dest(dest ? dest : process.cwd());
	}

	download.run(function (err, files) {
		if (err) {
			console.error(err);
			process.exit(1);
		}
{'fraction_non_alphanumeric': 0.21315859855576358, 'fraction_numerical': 0.003744316662209147, 'mean_word_length': 2.699307616221563, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 35, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '426730', 'n_tokens_mistral': 1416, 'n_tokens_neox': 1348, 'n_words': 330}