1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 | var grunt = require('../grunt');
|
11 |
|
12 |
|
13 | var path = require('path');
|
14 |
|
15 |
|
16 | grunt.task.init([], {help: true});
|
17 |
|
18 |
|
19 | var col1len = 0;
|
20 | var 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 |
|
27 | var 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 |
|
37 | grunt.log.writeln('grunt: a task-based command line build tool for JavaScript projects. (v' + grunt.version + ')');
|
38 |
|
39 | grunt.log.header('Usage');
|
40 | grunt.log.writeln(' ' + path.basename(process.argv[1]) + ' [options] [task [task ...]]');
|
41 |
|
42 |
|
43 | var widths = [1, col1len, 2, 76 - col1len];
|
44 |
|
45 | grunt.log.header('Options');
|
46 | opts.forEach(function(a) { grunt.log.writetableln(widths, ['', grunt.utils._.pad(a[0], col1len), '', a[1]]); });
|
47 |
|
48 | grunt.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 |
|
53 | grunt.log.header('Available tasks');
|
54 | tasks.forEach(function(a) { grunt.log.writetableln(widths, ['', grunt.utils._.pad(a[0], col1len), '', a[1]]); });
|
55 |
|
56 | grunt.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 |
|
69 | process.exit();
|