Class: MGit::GrepCommand
Instance Method Summary
collapse
Methods inherited from Command
#check_arity, create, execute, instance_each, list, load_commands, register_alias, register_command, require_commands_from_directory
Methods included from Output
#perror, #pinfo, #psystem, #ptable, #pwarn
Instance Method Details
#arity ⇒ Object
14
15
16
|
# File 'lib/mgit/commands/grep.rb', line 14
def arity
[1, 1]
end
|
#description ⇒ Object
22
23
24
|
# File 'lib/mgit/commands/grep.rb', line 22
def description
'grep for a pattern in each repository'
end
|
#execute(args) ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'lib/mgit/commands/grep.rb', line 5
def execute(args)
ptrn = args[0]
Registry.each do |repo|
pinfo "Looking for pattern '#{ptrn}' in repository #{repo.name}..."
System.git("grep '#{Shellwords.escape(ptrn)}'", chdir: repo.path, print_stdout: true)
end
end
|
#usage ⇒ Object
18
19
20
|
# File 'lib/mgit/commands/grep.rb', line 18
def usage
'grep <pattern>'
end
|