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

var program = require('commander'),
	winston = require('winston'),
	fs = require('fs'),
	path = require('path'),
	build = require('./lib/build'),
	u = require('./lib/util'),
	logger = new winston.Logger({
		transports: [
			new winston.transports.Console({
				handleExceptions: true,
				colorize: true
			})
		],
		exitOnError: false
	}),
	generate = function(entry, structure, options) {
		var filepath = u.mkdirp(u.getEntryPath.apply(u, arguments)),
			writeStream = fs.createWriteStream(filepath);
		logger.info('Created ', filepath);
		call(build.pipe, arguments).pipe(writeStream);
	},
	destroy = function(cmd, options) {
		console.log('Calling the destroyer');
		console.log(cmd, options);
	},
	call = function(fn, args) {
		fn.logger = logger;
		return fn.apply(fn, args);
	}

program.version("0.0.1");

program
	.command('generate <entry> <name> [options]')
	.description('Generates new entry')
	.option('-m, --module', 'Module name')
	.alias('g')
	.action(generate);

program
	.command('destroy <entry> <name> [options]')
	.description('Destroy entry, that was generated by "generate" command')
	.option('-m, --module', 'Module name')<commit_msg>Implemented 'destroy' option<commit_after>#!/usr/bin/env node

var program = require('commander'),
	winston = require('winston'),
	fs = require('fs'),
	path = require('path'),
	build = require('./lib/build'),
	u = require('./lib/util'),
	logger = new winston.Logger({
		transports: [
			new winston.transports.Console({
				handleExceptions: true,
				colorize: true
			})
		],
		exitOnError: false
	}),
	generate = function(entry, structure, options) {
		var filepath = u.mkdirp(u.getEntryPath.apply(u, arguments)),
			writeStream = fs.createWriteStream(filepath);
		logger.info('Created ', filepath);
		call(build.pipe, arguments).pipe(writeStream);
	},
	destroy = function(entry, structure, options) {
		var filepath = u.getEntryPath.apply(u, arguments);
		fs.unlink(filepath, function (err) {
			if (err) {
				if (err.code === 'ENOENT') {
					return logger.info('Nothing to remove');
				} else {
					throw err;
				}
			}
			logger.info('Removed ', filepath);
		});
	},
	call = function(fn, args) {
		fn.logger = logger;
		return fn.apply(fn, args);
	};

program.version("0.0.1");

program
	.command('generate <entry> <name>')
	.description('Generates new entry')
	.option('-m, --module <module>', 'Module name')
	.alias('g')
	.action(generate);

program
	.command('destroy <entry> <name>')
	.description('Destroy entry, that was generated by "generate" command')
	.option('-m, --module <module>', 'Module name')
{'fraction_non_alphanumeric': 0.18101798698813623, 'fraction_numerical': 0.002296211251435132, 'mean_word_length': 4.270161290322581, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '25654', 'n_tokens_mistral': 951, 'n_tokens_neox': 876, 'n_words': 196}