Search code examples
ruby-on-railsguard

Guard: How to run only certain group by default


I've defined 3 groups in my Guardfile, and I know I can use the -g parameter to run only the given groups.

But since I mostly want to run Guard with two specific groups: Is it possible to run these groups by default, without the parameter?


Solution

  • This is currently not possible with Guard, but some workaround comes to mind:

    Create an alias that evaluates only a specific group:

    $ alias guard=guard -g default

    Now only the group default group is used, but you can overwrite it:

    $ guard -g other

    You can also split your Guardfile, having your common plugins in it and extract the seldom used into another file, which you can use:

    $ guard -G Otherfile

    Since I also have the need for a better group management, I've planned to extend Guard to allow you to define the default groups in your Guardfile and add/remove more groups from the list of active groups from within the interactor.