89

I'm trying to work out how to print a list of all available grunt tasks. With rake it would be:

$ rake -T

What's the equivalent for grunt? e.g.

$ grunt -T

  • concat
  • jasmine
  • minify
crmpicco
  • 16,605
  • 26
  • 134
  • 210
opsb
  • 29,325
  • 19
  • 89
  • 99

2 Answers2

174

grunt --help lists available tasks.

tJener
  • 2,619
  • 1
  • 18
  • 20
  • 4
    ha! I completely missed that, saw the top section of commands but didn't notice the tasks were listed at the bottom... – opsb Feb 21 '13 at 20:09
  • 2
    @tJener how to you list the tasks of a multi task: `grunt multi:task0`, `multi:task1`, etc.? – Ciro Santilli OurBigBook.com Jun 15 '14 at 13:56
  • on a sidenote, a related interesting dicussion about being able to create a public or private task here: https://github.com/gruntjs/grunt/issues/741 – Michahell Sep 24 '14 at 22:59
  • 3
    @CiroSantilli I maintain a separate task listing module https://github.com/ben-eb/grunt-available-tasks which prints a task list, with multi-task targets, and without all of the noise that `grunt --help` generates. You might like to use it for now as a stop-gap, bearing in mind that it's been over a year since I first released it and still no option within grunt to hide tasks, etc. – Ben Dec 15 '14 at 11:03
4

Workaround for the list in sh/bash in case you need to trigger something and can't modify the original code:

grunt -h --no-color | sed -n '/^Available tasks/,/^$/ {s/^  *\([^ ]\+\)  [^ ]\+.*$/\1/p}'
estani
  • 24,254
  • 2
  • 93
  • 76
  • 1
    Sed program doesn't work: "/^Available tasks/,/^$/ ...": bad flag in substitute command: '}' – gotofritz Feb 02 '16 at 17:14
  • @gotofritz did you use single quotes? Double quotes have a different meaning check you sed documention otherwise. In case you use MacOs, it uses a different version of sed with a slightly different syntax. – estani Feb 03 '16 at 08:51
  • Yes, I was on OS X. But don't worry about it, I hardly use grunt these days anyway :-) – gotofritz Feb 05 '16 at 17:26