Class: MGit::GrepCommand

Inherits:
Command show all
Defined in:
lib/mgit/commands/grep.rb

Instance Method Summary collapse

Methods inherited from Command

#check_arity, execute, instance_each, list, load_commands, register_alias, register_command

Methods included from Output

#perror, #pinfo, #ptable, #pwarn

Instance Method Details

#arityObject



13
14
15
# File 'lib/mgit/commands/grep.rb', line 13

def arity
  [1, 1]
end

#descriptionObject



21
22
23
# File 'lib/mgit/commands/grep.rb', line 21

def description
  'grep for a pattern in each repository'
end

#execute(args) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/mgit/commands/grep.rb', line 3

def execute(args)
  ptrn = args[0]

  Registry.chdir_each do |repo|
    pinfo "Looking for pattern '#{ptrn}' in repository #{repo.name}..."
    puts `git grep #{ptrn}`
    puts
  end
end

#usageObject



17
18
19
# File 'lib/mgit/commands/grep.rb', line 17

def usage
  'grep <pattern>'
end