<commit_before>program = require "commander"
fs = require "fs"

program
	.version('0.1.0')
	.option('-d, --directory [dir]', 'directory to analyse', '.')
	.option('-u, --user <email>', 'user email adress to filter')
	.option('-t, --time [time]', 'git log since compatible time')

start = (email, directory) ->
	console.log "Scanning", directory, "for commits of user", email
	process.exit()


program.parse process.argv
<commit_msg>basic log parsing works, extract log from git archive<commit_after>program = require "commander"
fs = require "fs"
childProcess = require "child_process"
spawn = childProcess.spawn

program
	.version('0.1.0')
	.option('-d, --directory [dir]', 'directory to analyse', '.')
	.option('-u, --user <email>', 'user email adress to filter')
	.option('-t, --time [time]', 'git log since compatible time')
	
calcTime = (data) ->
	
	
parseLog = (log, user) ->
	lines = log.split "\n"
	console.log "User\t\t'#{user}'"
	data = []
	for line in lines
		[hash, email, subject, time] = line.split ';#;'
		if email is user
			data.push
				hash: hash,
				subject: subject
				time: Date.parse(time) / 1000	
	console.log "Found\t\t", data.length, "commits"
	calcTime data

start = (email, directory) ->
	console.log "Scanning \t'#{directory}'"
	log = spawn "git", ['log', '--pretty=format:%h;#;%ae;#;%s;#;%ad','--no-merges','--date=rfc'],
		cwd: directory
	logData = ""
	log.stdout.on "data", (data) ->
		logData+= data.toString 'utf8'
	log.stdout.on "end", () ->
		parseLog logData, email
	log.stderr.on "error", (data) ->
		console.log "error: ", data
	log.on "exit", (code) ->
		if code isnt 0
			console.log "exit with", code


program.parse process.argv

{'fraction_non_alphanumeric': 0.1917562724014337, 'fraction_numerical': 0.007168458781362007, 'mean_word_length': 3.7857142857142856, 'pattern_counts': {'":': 0, '<': 5, '<?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': '4397953', 'n_tokens_mistral': 634, 'n_tokens_neox': 604, 'n_words': 169}