UNPKG

2.3 kBJavaScriptView Raw
1/*
2 * grunt
3 * https://github.com/cowboy/grunt
4 *
5 * Copyright (c) 2012 "Cowboy" Ben Alman
6 * Licensed under the MIT license.
7 * http://benalman.com/about/license/
8 */
9
10var grunt = require('../grunt');
11
12// Nodejs libs.
13var path = require('path');
14
15// Initialize task system so that the tasks can be listed.
16grunt.task.init([], {help: true});
17
18// Build 2-column array for table view.
19var col1len = 0;
20var opts = Object.keys(grunt.cli.optlist).map(function(long) {
21 var o = grunt.cli.optlist[long];
22 var col1 = '--' + (o.negate ? 'no-' : '') + long + (o.short ? ', -' + o.short : '');
23 col1len = Math.max(col1len, col1.length);
24 return [col1, o.info];
25});
26
27var tasks = Object.keys(grunt.task._tasks).map(function(name) {
28 col1len = Math.max(col1len, name.length);
29 var info = grunt.task._tasks[name].info;
30 if (grunt.task._tasks[name].multi) {
31 info += ' *';
32 }
33 return [name, info];
34});
35
36// Actually write out help screen.
37grunt.log.writeln('grunt: a task-based command line build tool for JavaScript projects. (v' + grunt.version + ')');
38
39grunt.log.header('Usage');
40grunt.log.writeln(' ' + path.basename(process.argv[1]) + ' [options] [task [task ...]]');
41
42// Widths for options/tasks table output.
43var widths = [1, col1len, 2, 76 - col1len];
44
45grunt.log.header('Options');
46opts.forEach(function(a) { grunt.log.writetableln(widths, ['', grunt.utils._.pad(a[0], col1len), '', a[1]]); });
47
48grunt.log.writeln().writelns(
49 'Options marked with * have methods exposed via the grunt API and should ' +
50 'instead be specified inside the "grunt.js" gruntfile wherever possible.'
51);
52
53grunt.log.header('Available tasks');
54tasks.forEach(function(a) { grunt.log.writetableln(widths, ['', grunt.utils._.pad(a[0], col1len), '', a[1]]); });
55
56grunt.log.writeln().writelns(
57 'Tasks run in the order specified. Arguments may be passed to tasks that ' +
58 'accept them by using semicolons, like "lint:files". Tasks marked with * ' +
59 'are "multi tasks" and will iterate over all sub-targets if no argument is ' +
60 'specified.' +
61 '\n\n' +
62 'The list of available tasks may change based on tasks directories or ' +
63 'grunt plugins specified in the "grunt.js" gruntfile or via command-line ' +
64 'options.' +
65 '\n\n' +
66 'For more information, see https://github.com/cowboy/grunt'
67);
68
69process.exit();