Silence a specific guard plugin?

101 views Asked by At

I´m using guard-yard to automatically run YARD. However the output it has is really annoying and makes it hard to read the RSpec output (which is more interresting).

guard 'yard' do
  watch(%r{app/.+\.rb})
  watch(%r{lib/.+\.rb})
  watch(%r{ext/.+\.c})
end

Q. How do I silence the output of this Guard plugin?

3

There are 3 answers

0
Cezary Baginski On BEST ANSWER

Option 1: You may want to only run Yard if the tests pass:

group :stuff, halt_on_fail: true do
  guard :rspec, cmd: 'bundle exec rspec' do
    # (stuff for guard-rspec template goes here
  end

  guard :yard do
    watch(%r{app/.+\.rb})
    watch(%r{lib/.+\.rb})
    watch(%r{ext/.+\.c})
  end
end

or ...

Option 2: you may prefer to just skip yard when you're focused on RSpec:

guard :rspec, cmd: 'bundle exec rspec' do
  # (stuff for guard-rspec template goes here
end

guard :yard do
  watch(%r{app/.+\.rb})
  watch(%r{lib/.+\.rb})
  watch(%r{ext/.+\.c})
end

and limit guard to just running rspec bundle exec guard -g rspec

Option 3: use the scope command to switch between groups/plugins

You can also use the scope command in the Pry interactor to tell Guard what you're interested in running, e.g.

# tells guard to just run rspec
[1] guard(main)> scope rspec
[2] RSpec guard(main)>

# or just yard
[1] guard(main)> scope yard
[2] Yard guard(main)>

# or everything again
[1] guard(main)> scope default
[2] Default guard(main)>
3
nkipreos On

I had the same problem and I used interactor :off ate the beginning of the Guardfile, so your code should look like this:

interactor :off
guard 'yard' do
  watch(%r{app/.+\.rb})
  watch(%r{lib/.+\.rb})
  watch(%r{ext/.+\.c})
end

To run it in the background and not receive any output in the console you should run the command as:

bundle exec guard <options> >/dev/null 2>&1 &
0
Daniël W. Crompton On

The yard tool output can be redirected. AFAIK you can't disable all notifications for guard.

FWIW: This is the way I set up yard in my Guardfile to hide part of the output:

guard :yard, stdout: 'log/yard.log', stderr: 'log/yard_error.log' do watch(%r{app/.+\.rb}) watch(%r{lib/.+\.rb}) end