<commit_before>'use strict';

var os = require('os');

var clipboard = require('copy-paste').copy;
var inquirer = require('inquirer');
var pkg = require('../package');
var patchCliCursor = require('./patch-cli-cursor');

module.exports = function ipt(p, ttys, log, options, input, error) {
	function printHelp() {
		log.info(
			'\nUsage:\n  ipt [<path>]\n' +
			'\nSpecify a file <path> or pipe some data from stdin to start interacting.\n' +
			'\nOptions:\n' +
			'  -v --version       Displays app version number\n' +
			'  -h --help          Shows this help message\n' +
			'  -d --debug         Prints original node error messages to stderr on errors\n' +
			'  -e --file-encoding Sets a encoding to open <path> file, defaults to utf8\n' +
			'  -m --multiple      Allows the selection of multiple items\n' +
			'  -s --separator     Defines a separator to be used to split input into items\n' +
			'  -c --copy          Copy selected item(s) to clipboard\n' +
			'  --unquoted         Force the output to be unquoted\n'
		);
		p.exit(0);
	}

	function printVersion() {
		log.info(pkg.version);
		p.exit(0);
	}

	function end(data) {
		if (!Array.isArray(data)) {
			data = [data];
		}
		log.info(data.join(os.EOL));
		p.exit(0);
	}

	function formatResult(str) {
		if (options.unquoted) {
			return str;
		}

		return str.indexOf(' ') >= 0 ? '"' + str + '"' : str;
	}

	function onPrompt(answer) {
		var result = typeof answer.stdin === 'string' ?
			formatResult(answer.stdin) :
			answer.stdin.map(formatResult);

		if (options.copy) {
			try {
				clipboard(result, end.bind(null, result));
			} catch (e) {
				if (options.debug) {
					log.warn(e.toString());
				}
				end(result);
			}
		} else {
			end(result);
		}
	}

	function onForcedExit(e) {<commit_msg>Trim results prior to output<commit_after>'use strict';

var os = require('os');

var clipboard = require('copy-paste').copy;
var inquirer = require('inquirer');
var pkg = require('../package');
var patchCliCursor = require('./patch-cli-cursor');

module.exports = function ipt(p, ttys, log, options, input, error) {
	function printHelp() {
		log.info(
			'\nUsage:\n  ipt [<path>]\n' +
			'\nSpecify a file <path> or pipe some data from stdin to start interacting.\n' +
			'\nOptions:\n' +
			'  -v --version       Displays app version number\n' +
			'  -h --help          Shows this help message\n' +
			'  -d --debug         Prints original node error messages to stderr on errors\n' +
			'  -e --file-encoding Sets a encoding to open <path> file, defaults to utf8\n' +
			'  -m --multiple      Allows the selection of multiple items\n' +
			'  -s --separator     Defines a separator to be used to split input into items\n' +
			'  -c --copy          Copy selected item(s) to clipboard\n' +
			'  --unquoted         Force the output to be unquoted\n'
		);
		p.exit(0);
	}

	function printVersion() {
		log.info(pkg.version);
		p.exit(0);
	}

	function end(data) {
		if (!Array.isArray(data)) {
			data = [data];
		}
		log.info(data.join(os.EOL));
		p.exit(0);
	}

	function formatResult(str) {
		str = str.trim();

		if (options.unquoted) {
			return str;
		}

		return str.indexOf(' ') >= 0 ? '"' + str + '"' : str;
	}

	function onPrompt(answer) {
		var result = typeof answer.stdin === 'string' ?
			formatResult(answer.stdin) :
			answer.stdin.map(formatResult);

		if (options.copy) {
			try {
				clipboard(result, end.bind(null, result));
			} catch (e) {
				if (options.debug) {
					log.warn(e.toString());
				}
				end(result);
			}
		} else {
			end(result);
		}
	}

	function onForcedExit(e) {
{'fraction_non_alphanumeric': 0.15987723214285715, 'fraction_numerical': 0.0027901785714285715, 'mean_word_length': 2.635902636916836, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '2915049', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1260, 'n_words': 334}