<commit_before>'use strict';

let fs = require('fs');
let path = require('path');
let resolvePath = path.resolve;
let globSync = require('glob').sync;
let moment = require('moment');
let pad = require('pad');
let dateTimeFormat = require('./date-time-format');
let parseDate = require('./parse-date');
let parseParameter = require('./parse-parameter');

let handlers = globSync('cli-parsers/*.js').map(function(handlerPath) {
    return require(resolvePath(handlerPath));
});

module.exports = function(args) {
    let event = {};

    let dateTime = (function() {
        let dateTime = parseDate(args[0]);

        if(dateTime) {
            dateTime = moment(dateTime);
            args.shift();
        }
        else {
            dateTime = moment();
        }

        return dateTime;
    })();

    event.type = args.shift();

    args.forEach(function(arg) {
        var keyValue = /^([^:]+):(.+)$/.exec(arg);

        if(keyValue) {
            event[keyValue[1]] = parseParameter(keyValue[2]);
        }
        else {
            event.positionals = event.positionals || [];
            event.positionals.push(parseParameter(arg));
        }<commit_msg>Fix event date/time argument parsing.<commit_after>'use strict';

let fs = require('fs');
let path = require('path');
let resolvePath = path.resolve;
let globSync = require('glob').sync;
let moment = require('moment');
let pad = require('pad');
let dateTimeFormat = require('./date-time-format');
let parseDate = require('./parse-date');
let parseParameter = require('./parse-parameter');

let handlers = globSync('cli-parsers/*.js').map(function(handlerPath) {
    return require(resolvePath(handlerPath));
});

module.exports = function(args) {
    let event = {};

    let dateTime = (function() {
        let dateTime = parseDate(args[0].slice(1));

        if(dateTime) {
            dateTime = moment(dateTime);
            args.shift();
        }
        else {
            dateTime = moment();
        }

        return dateTime;
    })();

    event.type = args.shift();

    args.forEach(function(arg) {
        var keyValue = /^([^:]+):(.+)$/.exec(arg);

        if(keyValue) {
            event[keyValue[1]] = parseParameter(keyValue[2]);
        }
        else {
            event.positionals = event.positionals || [];
            event.positionals.push(parseParameter(arg));
        }
{'fraction_non_alphanumeric': 0.16871035940803383, 'fraction_numerical': 0.002959830866807611, 'mean_word_length': 2.606707317073171, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1720882', 'n_tokens_mistral': 694, 'n_tokens_neox': 673, 'n_words': 136}