<commit_before>/**
 * @fileoverview A parser for command line options. This parser supports
 * various option formats:
 *
 * <pre>-a -b -c (multiple short options)
 * -abc (multiple short options combined into one)
 * -a value (short option with value)
 * -avalue (alternative short option with value)
 * --option value (long option with value)
 * --option=value (alternative long option with value)</pre>
 */

var strings = require("ringo/utils/strings");

/**
 * Create a new command line option parser.
 */
exports.Parser = function() {
    var options = [];

    /**
     * Add an option to the parser.
     * @param {String} shortName the short option name (without leading hyphen)
     * @param {String} longName the long option name (without leading hyphens)
     * @param {String} argument the name of the argument if the option requires one, or null
     * @param {String} helpText the help text to display for the option
     */
    this.addOption = function(shortName, longName, argument, helpText) {
        if (shortName && shortName.length != 1) {
            throw new Error("Short option must be a string of length 1");
        }
        longName = longName || "";
        argument = argument || "";
        options.push({
            shortName: shortName,
            longName: longName,
            argument: argument,
            helpText: helpText
        });
    };

    /**
     * Get help text for the parser's options suitable for display in command line scripts.
     * @returns {String} a string explaining the parser's options
     */
    this.help = function() {
        var lines = [];<commit_msg>Return this in ringo/args.Parser.addOption() for chained operation<commit_after>/**
 * @fileoverview A parser for command line options. This parser supports
 * various option formats:
 *
 * <pre>-a -b -c (multiple short options)
 * -abc (multiple short options combined into one)
 * -a value (short option with value)
 * -avalue (alternative short option with value)
 * --option value (long option with value)
 * --option=value (alternative long option with value)</pre>
 */

var strings = require("ringo/utils/strings");

/**
 * Create a new command line option parser.
 */
exports.Parser = function() {
    var options = [];

    /**
     * Add an option to the parser.
     * @param {String} shortName the short option name (without leading hyphen)
     * @param {String} longName the long option name (without leading hyphens)
     * @param {String} argument the name of the argument if the option requires one, or null
     * @param {String} helpText the help text to display for the option
     * @returns {Object} this parser for chained invocation
     */
    this.addOption = function(shortName, longName, argument, helpText) {
        if (shortName && shortName.length != 1) {
            throw new Error("Short option must be a string of length 1");
        }
        longName = longName || "";
        argument = argument || "";
        options.push({
            shortName: shortName,
            longName: longName,
            argument: argument,
            helpText: helpText
        });
        return this;
    };

    /**
     * Get help text for the parser's options suitable for display in command line scripts.
     * @returns {String} a string explaining the parser's options
     */
    this.help = function() {
        var lines = [];
{'fraction_non_alphanumeric': 0.10395747194329592, 'fraction_numerical': 0.0011813349084465446, 'mean_word_length': 2.6070287539936103, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1963063', 'n_tokens_mistral': 889, 'n_tokens_neox': 871, 'n_words': 367}