<commit_before>/*
 * Copyright 2013, All Rights Reserved.
 *
 * Code licensed under the BSD License:
 * https://github.com/eduardolundgren/blob/master/LICENSE.md
 *
 * @author <NAME> <<EMAIL>>
 */

// -- Requires -----------------------------------------------------------------
var async = require('async'),
    base = require('../base'),
    clc = require('cli-color'),
    git = require('../git'),
    logger = require('../logger'),
    open = require('open'),
    url = require('url');

// -- Constructor --------------------------------------------------------------
function Repo(options) {
    this.options = options;
}

// -- Constants ----------------------------------------------------------------
Repo.DETAILS = {
    alias: 're',
    description: 'Provides a set of util commands to work with Repositories.',
    options: {
        'clone'         : Boolean,
        'description'   : String,
        'detailed'      : Boolean,
        'gitignore'     : String,
        'homepage'      : String,
        'init'          : Boolean,
        'list'          : Boolean,
        'new'           : String,
        'open'          : Boolean,
        'private'       : Boolean,
        'repo'          : String,
        'type'          : [ 'all', 'member', 'owner', 'public', 'private' ],
        'user'          : String
    },
    shorthands: {
        'c': [ '--clone' ],
        'd': [ '--detailed' ],
        'l': [ '--list' ],
        'n': [ '--new' ],
        'o': [ '--open' ],
        'p': [ '--private' ],
        'r': [ '--repo' ],
        't': [ '--type' ],
        'u': [ '--user' ]
    },
    payload: function(payload, options) {
        options.open = true;
    }
};

Repo.TYPE_ALL = 'all';
Repo.TYPE_MEMBER = 'member';
Repo.TYPE_OWNER = 'owner';
Repo.TYPE_PRIVATE = 'private';
Repo.TYPE_PUBLIC = 'public';

// -- Commands -----------------------------------------------------------------
Repo.prototype.run = function() {
    var instance = this,
        options = instance.options,
        config = base.getGlobalConfig();

    options.type = options.type || Repo.TYPE_ALL;

    if (options.list) {
        logger.logTemplate('{{prefix}} [info] Listing {{greenBright options.type}} repos for {{greenBright options.user}}', {
            options: options
        });

        instance.list(options.user, function(err) {
            logger.defaultCallback(err, null, false);
        });
    }

    if (options.new) {
        logger.logTemplate('{{prefix}} [info] Creating a new repo on {{greenBright options.user "/" options.new}}', {
            options: options
        });

        instance.new(function(err1, repo) {
            if (repo) {
                options.id = repo.id;

                if (config.open_repo_in_browser) {
                    open(repo.html_url);
                }

                if (options.clone) {
                    git.clone(
                        url.parse(repo.ssh_url).href,
                        null,
                        function(err2, data) {
                            console.log(data);
                        });
                }
            }

            logger.defaultCallback(
                err1, null, logger.compileTemplate('{{repoLink}}', { options: options }));
        });
    }

    if (options.open) {
        instance.open(options.user, options.repo);
    }
};<commit_msg>Fix #119<commit_after>/*
 * Copyright 2013, All Rights Reserved.
 *
 * Code licensed under the BSD License:
 * https://github.com/eduardolundgren/blob/master/LICENSE.md
 *
 * @author <NAME> <<EMAIL>>
 */

// -- Requires -----------------------------------------------------------------
var async = require('async'),
    base = require('../base'),
    clc = require('cli-color'),
    git = require('../git'),
    logger = require('../logger'),
    open = require('open'),
    url = require('url');

// -- Constructor --------------------------------------------------------------
function Repo(options) {
    this.options = options;
}

// -- Constants ----------------------------------------------------------------
Repo.DETAILS = {
    alias: 're',
    description: 'Provides a set of util commands to work with Repositories.',
    options: {
        'clone'         : Boolean,
        'description'   : String,
        'detailed'      : Boolean,
        'gitignore'     : String,
        'homepage'      : String,
        'init'          : Boolean,
        'list'          : Boolean,
        'new'           : String,
        'open'          : Boolean,
        'private'       : Boolean,
        'repo'          : String,
        'type'          : [ 'all', 'member', 'owner', 'public', 'private' ],
        'user'          : String
    },
    shorthands: {
        'c': [ '--clone' ],
        'd': [ '--detailed' ],
        'l': [ '--list' ],
        'n': [ '--new' ],
        'o': [ '--open' ],
        'p': [ '--private' ],
        'r': [ '--repo' ],
        't': [ '--type' ],
        'u': [ '--user' ]
    },
    payload: function(payload, options) {
        options.open = true;
    }
};

Repo.TYPE_ALL = 'all';
Repo.TYPE_MEMBER = 'member';
Repo.TYPE_OWNER = 'owner';
Repo.TYPE_PRIVATE = 'private';
Repo.TYPE_PUBLIC = 'public';

// -- Commands -----------------------------------------------------------------
Repo.prototype.run = function() {
    var instance = this,
        options = instance.options,
        config = base.getGlobalConfig();

    options.type = options.type || Repo.TYPE_ALL;

    if (options.list) {
        logger.logTemplate('{{prefix}} [info] Listing {{greenBright options.type}} repos for {{greenBright options.user}}', {
            options: options
        });

        instance.list(options.user, function(err) {
            logger.defaultCallback(err, null, false);
        });
    }

    if (options.new) {
        options.user = options.loggedUser;
        options.repo = options.new;

        logger.logTemplate('{{prefix}} [info] Creating a new repo on {{greenBright options.user "/" options.new}}', {
            options: options
        });

        instance.new(function(err1, repo) {
            if (repo) {
                options.id = repo.id;

                if (config.open_repo_in_browser) {
                    open(repo.html_url);
                }

                if (options.clone) {
                    git.clone(
                        url.parse(repo.ssh_url).href,
                        null,
                        function(err2, data) {
                            console.log(data);
                        });
                }
            }

            logger.defaultCallback(
                err1, null, logger.compileTemplate('{{repoLink}}', { options: options }));
        });
    }

    if (options.open) {
        instance.open(options.user, options.repo);
    }
};
{'fraction_non_alphanumeric': 0.22445979714831693, 'fraction_numerical': 0.0024988975452006467, 'mean_word_length': 1.297872340425532, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '3899548', 'n_tokens_mistral': 1908, 'n_tokens_neox': 1856, 'n_words': 383}