Search code examples
rubyguardyard

Silence a specific guard plugin?


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?


Solution

  • 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)>