How to use the cli function from grunt

Find comprehensive JavaScript grunt.cli code examples handpicked from public code repositorys.

44
45
46
47
48
49
50
51
52
53
  grunt.cli.tasks = ['init'];
} else {
  name = grunt.cli.tasks[0];
  // For the specified "task" prepend "init:" so the init task doesn't
  // actually need to be specified on the command line.
  grunt.cli.tasks = ['init:' + name];
}

// Remove grunt options that don't really make any sense for grunt-init.
[
fork icon71
star icon191
watch icon0

+ 7 other calls in file

92
93
94
95
96
97
98
99
100
101
});

var tasks = map(enyoTasks, grunt.task._tasks);
var inits = map(enyoInits, initDefs);
var bowers = map(enyoBowers, grunt.task._tasks);
var opts = map(enyoOptions, grunt.cli.optlist, true);

function displayTasks(header, tasks) {

  grunt.log.header(header.cyan.bold);
fork icon7
star icon10
watch icon5

55
56
57
58
59
60
61
62

function runTask() {
  grunt.task.loadTasks(path.join(__dirname, '../node_modules/grunt-init/tasks'));
  // fix windows directory by replace C:\ to C\:\
  var taskName = 'init:' + template.replace(/^([a-zA-Z]):\\/, '$1\\:\\');
  grunt.cli.tasks = [taskName];
  grunt.cli({});
}
fork icon3
star icon5
watch icon10

+ 3 other calls in file

42
43
44
45
46
47
48
49
50
51

// Borrowed heavily from the Grunt help source.
var col1len = 0;

var opts = Object.keys(grunt.cli.optlist).map(function(long) {
  var o = grunt.cli.optlist[long];
  var col1 = '--' + (o.negate ? 'no-' : '') + long + (o.short ? ', -' + o.short : '');
  col1len = Math.max(col1len, col1.length);
  return [col1, o.info];
});
fork icon0
star icon4
watch icon2

79
80
81
82
83
84
85
    // Do not proceed further.
    return displayHelp();
  }

  // Otherwise, invoke the CLI.
  grunt.cli();
});
fork icon0
star icon0
watch icon2

+ 15 other calls in file