Permalink
Browse files

[cdstk] gotolineモード(-g)で、複数のパスを渡せるように

  $ gmilk -g lib/database.rb:7 test/test_database.rb:5
  lib/database.rb:7:xxxxxxxxxxxxxxx
  test/test_database.rb:5:yyyyyyyyy
  • Loading branch information...
1 parent 5c24057 commit 0812eae7e3b08ed50cfde4ca8b9c65f4cad06703 @ongaeshi committed Apr 2, 2012
Showing with 18 additions and 7 deletions.
  1. +1 −1 lib/milkode/common/util.rb
  2. +14 −3 lib/milkode/grep/cli_grep.rb
  3. +3 −3 test/test_util.rb
@@ -111,7 +111,7 @@ def parse_gotoline(words)
if gotoline_multi?(words)
parse_gotoline_multi(words)
else
- parse_gotoline_single(words)
+ [parse_gotoline_single(words)]
end
end
@@ -46,6 +46,10 @@ def self.execute(stdout, arguments=[])
lib/database.rb:7:xxxxxxxxxxxxxxx
database_lib.rb:7:yyyyyyyyyyyyyyy
+ gmilk -g lib/database.rb:7 test/test_database.rb:5
+ lib/database.rb:7:xxxxxxxxxxxxxxx
+ test/test_database.rb:5:yyyyyyyyy
+
Normal:
EOF
opt.on('-a', '--all', 'Search all package.') {|v| my_option[:all] = true }
@@ -77,10 +81,8 @@ def self.execute(stdout, arguments=[])
my_option[:find_mode] = true unless ap.keywords.empty?
unless ap.gotowords.empty?
- r = Util::parse_gotoline(ap.gotowords)
- option.filePatterns += r[0]
- option.gotoline = r[1]
my_option[:find_mode] = true
+ my_option[:gotoline_data] = Util::parse_gotoline(ap.gotowords)
end
# p ap.arguments
@@ -130,6 +132,15 @@ def self.execute(stdout, arguments=[])
records = findGrep.pickupRecords
# stdout.puts "#{records.size} records (#{findGrep.time_s})"
stdout.puts "#{records.size} records"
+ elsif (my_option[:gotoline_data])
+ # gotoline mode
+ basePatterns = option.filePatterns
+ my_option[:gotoline_data].each do |v|
+ option.filePatterns = basePatterns + v[0]
+ option.gotoline = v[1]
+ findGrep = FindGrep::FindGrep.new(arguments, option)
+ findGrep.searchAndPrint(stdout)
+ end
else
# search mode
findGrep = FindGrep::FindGrep.new(arguments, option)
View
@@ -72,9 +72,9 @@ def test_downcase?
end
def test_parse_gotoline
- assert_equal [['a', 'b'], 123], Milkode::Util::parse_gotoline(['a', '123', 'b'])
- assert_equal [['a', '123', 'b'], 55], Milkode::Util::parse_gotoline(['a', '123', 'b', '55'])
- assert_equal [['a', 'b'], 1], Milkode::Util::parse_gotoline(['a', 'b'])
+ assert_equal [[['a', 'b'], 123]], Milkode::Util::parse_gotoline(['a', '123', 'b'])
+ assert_equal [[['a', '123', 'b'], 55]], Milkode::Util::parse_gotoline(['a', '123', 'b', '55'])
+ assert_equal [[['a', 'b'], 1]], Milkode::Util::parse_gotoline(['a', 'b'])
assert_equal [[['a'], 55]], Milkode::Util::parse_gotoline(['a:55'])
assert_equal [[['lib/aaa.c'], 8], [['test/bbb.rb'], 9]], Milkode::Util::parse_gotoline(['lib/aaa.c:8', 'test/bbb.rb:9'])
assert_equal [[['c:/tmp/ccc.txt'], 99]], Milkode::Util::parse_gotoline(['c:/tmp/ccc.txt:99'])

0 comments on commit 0812eae

Please sign in to comment.