Sha256: 61bccb7ca5238ad6bf0daf9ae7a7ec8c1a45bd00967ecf3da3d98945030c5713

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

/*
 Copyright (c) 2012, Yahoo! Inc.  All rights reserved.
 Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
 */

var Command = require('./index.js'),
    util = require('util'),
    formatOption = require('../util/help-formatter').formatOption,
    VERSION = require('../../index').VERSION;

function HelpCommand() {
    Command.call(this);
}

HelpCommand.TYPE = 'help';
util.inherits(HelpCommand, Command);

Command.mix(HelpCommand, {
    synopsis: function () {
        return "shows help";
    },

    usage: function () {

        util.error('\nUsage: ' + this.toolName() + ' ' + this.type() + ' <command>\n');
        util.error('Available commands are:\n');

        var commandObj;
        Command.getCommandList().forEach(function (cmd) {
            commandObj = Command.create(cmd);
            util.error(formatOption(cmd, commandObj.synopsis()));
            util.error("\n");
        });
        util.error("Command names can be abbreviated as long as the abbreviation is unambiguous");
        util.error(this.toolName() + ' version:' + VERSION);
        util.error("\n");
    },
    run: function (args, callback) {
        var command;
        if (args.length === 0) {
            this.usage();
        } else {
            try {
                command = Command.create(args[0]);
                command.usage('istanbul', Command.resolveCommandName(args[0]));
            } catch (ex) {
                util.error('Invalid command: ' + args[0]);
                this.usage();
            }
        }
        return callback();
    }
});


module.exports = HelpCommand;


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cssesc-source-0.1.0 vendor/node_modules/istanbul/lib/command/help.js