gren 0.3.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +7 -0
- data/{History.ja.txt → HISTORY.ja.md} +41 -15
- data/HISTORY.md +92 -0
- data/LICENSE.txt +22 -0
- data/README.ja.md +57 -0
- data/README.md +51 -0
- data/Rakefile +9 -39
- data/bin/gren +2 -7
- data/gren.gemspec +21 -0
- data/lib/gren.rb +3 -3
- data/lib/gren/cli.rb +13 -10
- data/lib/{common → gren/common}/grenfiletest.rb +0 -0
- data/lib/{common → gren/common}/grensnip.rb +1 -1
- data/lib/{common → gren/common}/platform.rb +0 -0
- data/lib/{common → gren/common}/string_snip.rb +0 -0
- data/lib/{common → gren/common}/util.rb +16 -10
- data/lib/{findgrep → gren/findgrep}/findgrep.rb +47 -143
- data/lib/{findgrep → gren/findgrep}/result.rb +1 -1
- data/lib/gren/version.rb +3 -0
- data/test/data/aaa.txt +1 -0
- data/test/data/abc.rb +8 -0
- data/test/data/bbb.txt +1 -0
- data/test/data/ccc.c +1 -0
- data/test/data/sub/ccc.txt +1 -0
- data/test/test_cli.rb +80 -0
- data/test/test_gren.rb +10 -10
- data/test/test_gren_util.rb +3 -2
- data/test/test_string_snip.rb +31 -31
- metadata +67 -177
- data/History.txt +0 -66
- data/Manifest.txt +0 -48
- data/PostInstall.txt +0 -7
- data/README.rdoc +0 -181
- data/bin/grendb +0 -11
- data/bin/grenweb +0 -11
- data/bin/mkgrendb +0 -11
- data/lib/common/display_util.rb +0 -62
- data/lib/grendb/cli.rb +0 -41
- data/lib/grenweb/cli.rb +0 -52
- data/lib/grenweb/database.rb +0 -179
- data/lib/grenweb/grenweb.ru +0 -35
- data/lib/grenweb/grep.rb +0 -52
- data/lib/grenweb/help.rb +0 -39
- data/lib/grenweb/home.rb +0 -39
- data/lib/grenweb/html_renderer.rb +0 -243
- data/lib/grenweb/public/css/gren.css +0 -63
- data/lib/grenweb/public/images/gren-icon-mini.png +0 -0
- data/lib/grenweb/public/images/gren-icon.png +0 -0
- data/lib/grenweb/query.rb +0 -82
- data/lib/grenweb/searcher.rb +0 -129
- data/lib/grenweb/viewer.rb +0 -51
- data/lib/mkgrendb/cli.rb +0 -49
- data/lib/mkgrendb/mkgrendb.rb +0 -230
- data/rake_rdoc_custom.rb +0 -13
- data/script/console +0 -10
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/test/test_grenweb_cli.rb +0 -10
- data/test/test_grenweb_html_renderer.rb +0 -41
- data/test/test_grenweb_query.rb +0 -54
- data/test/test_grenweb_searcher.rb +0 -35
data/History.txt
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
=== 0.3.2 2011/02/20
|
2
|
-
|
3
|
-
* mkgrendb
|
4
|
-
* Bugfix
|
5
|
-
|
6
|
-
=== 0.3.1 2010/11/20
|
7
|
-
|
8
|
-
* grenweb
|
9
|
-
|
10
|
-
=== 0.3.0 2010/11/02
|
11
|
-
|
12
|
-
* grenweb
|
13
|
-
* mkgrendb
|
14
|
-
|
15
|
-
=== 0.2.4 2010/10/09
|
16
|
-
|
17
|
-
* mkgrendb
|
18
|
-
* grendb
|
19
|
-
|
20
|
-
=== 0.2.3 2010/09/25
|
21
|
-
|
22
|
-
* mkgrendb
|
23
|
-
|
24
|
-
=== 0.2.2 2010/09/14
|
25
|
-
|
26
|
-
* mkgrendb
|
27
|
-
|
28
|
-
=== 0.2.1 2010/09/13
|
29
|
-
|
30
|
-
* gren
|
31
|
-
|
32
|
-
=== 0.2.0 2010/09/13
|
33
|
-
|
34
|
-
* grendb
|
35
|
-
|
36
|
-
=== 0.1.4 2010/08/14
|
37
|
-
|
38
|
-
* gren
|
39
|
-
* snip-mode
|
40
|
-
|
41
|
-
=== 0.1.3 2010/08/13
|
42
|
-
|
43
|
-
* gren
|
44
|
-
|
45
|
-
=== 0.1.2 2010/08/05
|
46
|
-
|
47
|
-
* gren
|
48
|
-
* Bug fix.
|
49
|
-
|
50
|
-
=== 0.1.1 2010/08/04
|
51
|
-
|
52
|
-
* gren
|
53
|
-
|
54
|
-
=== 0.1.0 2010/08/02
|
55
|
-
|
56
|
-
* Update README.doc (to English).
|
57
|
-
|
58
|
-
=== 0.0.6 2010/07/29
|
59
|
-
|
60
|
-
* update github
|
61
|
-
* http://github.com/ongaeshi/gren
|
62
|
-
|
63
|
-
=== 0.0.1 2010-07-22
|
64
|
-
|
65
|
-
* 1 major enhancement:
|
66
|
-
* Initial release
|
data/Manifest.txt
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
History.ja.txt
|
2
|
-
History.txt
|
3
|
-
Manifest.txt
|
4
|
-
PostInstall.txt
|
5
|
-
README.rdoc
|
6
|
-
Rakefile
|
7
|
-
bin/gren
|
8
|
-
bin/grendb
|
9
|
-
bin/grenweb
|
10
|
-
bin/mkgrendb
|
11
|
-
lib/common/display_util.rb
|
12
|
-
lib/common/grenfiletest.rb
|
13
|
-
lib/common/grensnip.rb
|
14
|
-
lib/common/platform.rb
|
15
|
-
lib/common/string_snip.rb
|
16
|
-
lib/common/util.rb
|
17
|
-
lib/findgrep/findgrep.rb
|
18
|
-
lib/findgrep/result.rb
|
19
|
-
lib/gren.rb
|
20
|
-
lib/gren/cli.rb
|
21
|
-
lib/grendb/cli.rb
|
22
|
-
lib/grenweb/cli.rb
|
23
|
-
lib/grenweb/database.rb
|
24
|
-
lib/grenweb/grenweb.ru
|
25
|
-
lib/grenweb/grep.rb
|
26
|
-
lib/grenweb/help.rb
|
27
|
-
lib/grenweb/home.rb
|
28
|
-
lib/grenweb/html_renderer.rb
|
29
|
-
lib/grenweb/public/css/gren.css
|
30
|
-
lib/grenweb/public/images/gren-icon-mini.png
|
31
|
-
lib/grenweb/public/images/gren-icon.png
|
32
|
-
lib/grenweb/query.rb
|
33
|
-
lib/grenweb/searcher.rb
|
34
|
-
lib/grenweb/viewer.rb
|
35
|
-
lib/mkgrendb/cli.rb
|
36
|
-
lib/mkgrendb/mkgrendb.rb
|
37
|
-
rake_rdoc_custom.rb
|
38
|
-
script/console
|
39
|
-
script/destroy
|
40
|
-
script/generate
|
41
|
-
test/test_gren.rb
|
42
|
-
test/test_gren_util.rb
|
43
|
-
test/test_grenweb_cli.rb
|
44
|
-
test/test_grenweb_html_renderer.rb
|
45
|
-
test/test_grenweb_query.rb
|
46
|
-
test/test_grenweb_searcher.rb
|
47
|
-
test/test_helper.rb
|
48
|
-
test/test_string_snip.rb
|
data/PostInstall.txt
DELETED
data/README.rdoc
DELETED
@@ -1,181 +0,0 @@
|
|
1
|
-
= gren (grep next)
|
2
|
-
|
3
|
-
http://ongaeshi.github.com/gren
|
4
|
-
|
5
|
-
== DESCRIPTION:
|
6
|
-
gren is a next grep tool.
|
7
|
-
|
8
|
-
== CONCEPT:
|
9
|
-
|
10
|
-
* The basis is find+grep.
|
11
|
-
* The item that the user specifies to the minimum
|
12
|
-
* The binary or the text or the tool judges it from the automatic operation.
|
13
|
-
* Convenient retrieval result
|
14
|
-
|
15
|
-
== INSTALL:
|
16
|
-
gem install gren
|
17
|
-
|
18
|
-
== USAGE:
|
19
|
-
gren [option] pattern [dir]
|
20
|
-
-i, --ignore Ignore case.
|
21
|
-
-l, --listing The searched file name is displayed.
|
22
|
-
-f, --file-regexp REGEXP Search file regexp. (default: ".")
|
23
|
-
--if, --ignore-file REGEXP Ignore file pattern.
|
24
|
-
--id, --ignore-dir REGEXP Ignore dir pattern.
|
25
|
-
|
26
|
-
== SAMPLE:
|
27
|
-
=== "FileTest" is retrieved below the present directory.
|
28
|
-
% gren FileTest
|
29
|
-
pkg/gren-0.0.5/lib/gren/findgrep.rb:34: next unless FileTest.file?(fpath)
|
30
|
-
pkg/gren-0.0.5/lib/gren/findgrep.rb:39: unless FileTest.readable?(fpath)
|
31
|
-
pkg/gren-0.0.5/lib/gren/findgrep.rb:44: @result.size += FileTest.size(fpath)
|
32
|
-
pkg/gren-0.0.5/lib/gren/findgrep.rb:53: @result.search_size += FileTest.size(fpath)
|
33
|
-
pkg/gren-0.0.5/lib/gren/findgrep.rb:95: FileTest.directory?(fpath) &&
|
34
|
-
pkg/gren-0.0.4/lib/gren/findgrep.rb:34: next unless FileTest.file?(fpath)
|
35
|
-
pkg/gren-0.0.4/lib/gren/findgrep.rb:39: unless FileTest.readable?(fpath)
|
36
|
-
pkg/gren-0.0.4/lib/gren/findgrep.rb:44: @result.size += FileTest.size(fpath)
|
37
|
-
pkg/gren-0.0.4/lib/gren/findgrep.rb:53: @result.search_size += FileTest.size(fpath)
|
38
|
-
pkg/gren-0.0.4/lib/gren/findgrep.rb:95: FileTest.directory?(fpath) &&
|
39
|
-
lib/gren/findgrep.rb:34: next unless FileTest.file?(fpath)
|
40
|
-
lib/gren/findgrep.rb:39: unless FileTest.readable?(fpath)
|
41
|
-
lib/gren/findgrep.rb:44: @result.size += FileTest.size(fpath)
|
42
|
-
lib/gren/findgrep.rb:53: @result.search_size += FileTest.size(fpath)
|
43
|
-
lib/gren/findgrep.rb:95: FileTest.directory?(fpath) &&
|
44
|
-
|
45
|
-
dir : /Users/ongaeshi/Documents/gren (0.01sec)
|
46
|
-
files : 49 in 53 (35.63KB in 61.53KB)
|
47
|
-
match : 3 files, 15 hit
|
48
|
-
|
49
|
-
=== "FileTest" is retrieved below the directory pkg/
|
50
|
-
% gren FileTest pkg/
|
51
|
-
pkg/gren-0.0.5/lib/gren/findgrep.rb:34: next unless FileTest.file?(fpath)
|
52
|
-
pkg/gren-0.0.5/lib/gren/findgrep.rb:39: unless FileTest.readable?(fpath)
|
53
|
-
pkg/gren-0.0.5/lib/gren/findgrep.rb:44: @result.size += FileTest.size(fpath)
|
54
|
-
pkg/gren-0.0.5/lib/gren/findgrep.rb:53: @result.search_size += FileTest.size(fpath)
|
55
|
-
pkg/gren-0.0.5/lib/gren/findgrep.rb:95: FileTest.directory?(fpath) &&
|
56
|
-
pkg/gren-0.0.4/lib/gren/findgrep.rb:34: next unless FileTest.file?(fpath)
|
57
|
-
pkg/gren-0.0.4/lib/gren/findgrep.rb:39: unless FileTest.readable?(fpath)
|
58
|
-
pkg/gren-0.0.4/lib/gren/findgrep.rb:44: @result.size += FileTest.size(fpath)
|
59
|
-
pkg/gren-0.0.4/lib/gren/findgrep.rb:53: @result.search_size += FileTest.size(fpath)
|
60
|
-
pkg/gren-0.0.4/lib/gren/findgrep.rb:95: FileTest.directory?(fpath) &&
|
61
|
-
|
62
|
-
dir : /Users/ongaeshi/Documents/gren/pkg (0.01sec)
|
63
|
-
files : 32 in 36 (22.64KB in 48.54KB)
|
64
|
-
match : 2 files, 10 hit
|
65
|
-
|
66
|
-
=== Below the directory pkg/. It limits to the rb file and "FILE" is retrieved, that is, (file: 32 in 36 → file: 14 It is paid attention that it is in 36. )
|
67
|
-
% gren FILE -f "\.rb$"
|
68
|
-
pkg/gren-0.0.5/test/test_helper.rb:3:require File.dirname(__FILE__) + '/../lib/gren'
|
69
|
-
.
|
70
|
-
.
|
71
|
-
.
|
72
|
-
pkg/gren-0.0.4/lib/gren/cli.rb:3:require File.join(File.dirname(__FILE__), 'findgrep')
|
73
|
-
|
74
|
-
dir : /Users/ongaeshi/Documents/gren/pkg (0.1sec)
|
75
|
-
files : 14 in 36 (15.36KB in 48.54KB)
|
76
|
-
match : 12 files, 18 hit
|
77
|
-
|
78
|
-
=== --id ignore directory
|
79
|
-
% gren FILE -f "\.rb$" --id pkg
|
80
|
-
test/test_helper.rb:3:require File.dirname(__FILE__) + '/../lib/gren'
|
81
|
-
test/test_gren_cli.rb:1:require File.join(File.dirname(__FILE__), "test_helper.rb")
|
82
|
-
test/test_gren.rb:1:require File.dirname(__FILE__) + '/test_helper.rb'
|
83
|
-
lib/gren.rb:1:$:.unshift(File.dirname(__FILE__)) unless
|
84
|
-
lib/gren.rb:2: $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
85
|
-
lib/gren/findgrep.rb:3:require File.join(File.dirname(__FILE__), 'result')
|
86
|
-
lib/gren/findgrep.rb:7: IGNORE_FILE = /(\A#.*#\Z)|(~\Z)|(\A\.#)/
|
87
|
-
lib/gren/findgrep.rb:103: IGNORE_FILE.match(File.basename(fpath)) ||
|
88
|
-
lib/gren/cli.rb:3:require File.join(File.dirname(__FILE__), 'findgrep')
|
89
|
-
|
90
|
-
dir : /Users/ongaeshi/Documents/gren (0.01sec)
|
91
|
-
files : 7 in 17 (7.68KB in 11.32KB)
|
92
|
-
match : 6 files, 9 hit
|
93
|
-
|
94
|
-
=== --if ignore files
|
95
|
-
% gren FILE -f "\.rb$" --id pkg --if "test_.+\.rb$"
|
96
|
-
lib/gren.rb:1:$:.unshift(File.dirname(__FILE__)) unless
|
97
|
-
lib/gren.rb:2: $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
98
|
-
lib/gren/findgrep.rb:3:require File.join(File.dirname(__FILE__), 'result')
|
99
|
-
lib/gren/findgrep.rb:7: IGNORE_FILE = /(\A#.*#\Z)|(~\Z)|(\A\.#)/
|
100
|
-
lib/gren/findgrep.rb:103: IGNORE_FILE.match(File.basename(fpath)) ||
|
101
|
-
lib/gren/cli.rb:3:require File.join(File.dirname(__FILE__), 'findgrep')
|
102
|
-
|
103
|
-
dir : /Users/ongaeshi/Documents/gren (0.0sec)
|
104
|
-
files : 4 in 17 (7.07KB in 11.32KB)
|
105
|
-
match : 3 files, 6 hit
|
106
|
-
|
107
|
-
=== -i ignore case
|
108
|
-
% gren FILE -i -f "\.rb$" --id pkg --if "test_.+\.rb$"
|
109
|
-
lib/gren.rb:1:$:.unshift(File.dirname(__FILE__)) unless
|
110
|
-
lib/gren.rb:2: $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
111
|
-
lib/gren/result.rb:8: attr_accessor :match_file_count
|
112
|
-
.
|
113
|
-
.
|
114
|
-
.
|
115
|
-
lib/gren/cli.rb:16: opt.on('--if REGEXP', '--ignore-file REGEXP', 'Ignore file pattern.') {|v| option.ignoreFile = v}
|
116
|
-
|
117
|
-
dir : /Users/ongaeshi/Documents/gren (0.1sec)
|
118
|
-
files : 4 in 17 (7.07KB in 11.32KB)
|
119
|
-
match : 4 files, 53 hit
|
120
|
-
|
121
|
-
=== -l listing mode.
|
122
|
-
% gren FILE -l
|
123
|
-
test/test_helper.rb:3:require File.dirname(__FILE__) + '/../lib/gren'
|
124
|
-
.
|
125
|
-
.
|
126
|
-
|
127
|
-
--- search --------
|
128
|
-
test/test_helper.rb
|
129
|
-
test/test_gren_cli.rb
|
130
|
-
.
|
131
|
-
.
|
132
|
-
total: 49
|
133
|
-
|
134
|
-
--- match --------
|
135
|
-
test/test_helper.rb
|
136
|
-
test/test_gren_cli.rb
|
137
|
-
.
|
138
|
-
.
|
139
|
-
total: 30
|
140
|
-
|
141
|
-
--- ignore-file --------
|
142
|
-
pkg/gren-0.0.5.tgz
|
143
|
-
pkg/gren-0.0.5.gem
|
144
|
-
.
|
145
|
-
.
|
146
|
-
total: 4
|
147
|
-
|
148
|
-
--- ignore-dir --------
|
149
|
-
.git
|
150
|
-
total: 1
|
151
|
-
|
152
|
-
--- unreadable --------
|
153
|
-
total: 0
|
154
|
-
|
155
|
-
|
156
|
-
dir : /Users/ongaeshi/Documents/gren (0.01sec)
|
157
|
-
files : 49 in 53 (33.96KB in 59.86KB)
|
158
|
-
match : 30 files, 42 hit
|
159
|
-
|
160
|
-
=== The extra: It ego searches by my home directory
|
161
|
-
% cd ~
|
162
|
-
% gren ongaeshi
|
163
|
-
.
|
164
|
-
.
|
165
|
-
.
|
166
|
-
|
167
|
-
dir : /Users/ongaeshi (8m 52.45s)
|
168
|
-
files : 70237 in 153566 (713.45MB in 91.92GB)
|
169
|
-
match : 44 files, 162 hit
|
170
|
-
|
171
|
-
== for Emacs:
|
172
|
-
for OSX
|
173
|
-
(global-set-key "\C-x\C-g" 'grep-find) ; your favarite key
|
174
|
-
(setq grep-find-command "gren ")
|
175
|
-
|
176
|
-
for Windows
|
177
|
-
(global-set-key "\C-x\C-g" 'grep-find) ; your favarite key
|
178
|
-
(setq grep-find-command "gren.bat ")
|
179
|
-
|
180
|
-
== LICENSE:
|
181
|
-
MIT License
|
data/bin/grendb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Created on 2010-8-25.
|
4
|
-
# Copyright (c) 2010. All rights reserved.
|
5
|
-
|
6
|
-
require 'rubygems'
|
7
|
-
require File.expand_path(File.dirname(__FILE__) + "/../lib/gren")
|
8
|
-
require "grendb/cli"
|
9
|
-
|
10
|
-
Version = "0.2.4"
|
11
|
-
Grendb::CLI.execute(STDOUT, ARGV)
|
data/bin/grenweb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Created on 2010-10-10.
|
4
|
-
# Copyright (c) 2010. All rights reserved.
|
5
|
-
|
6
|
-
require 'rubygems'
|
7
|
-
require File.expand_path(File.dirname(__FILE__) + "/../lib/gren")
|
8
|
-
require "grenweb/cli"
|
9
|
-
|
10
|
-
Version = "0.3.1"
|
11
|
-
Grenweb::CLI.execute(STDOUT, ARGV)
|
data/bin/mkgrendb
DELETED
@@ -1,11 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# Created on 2010-9-12.
|
4
|
-
# Copyright (c) 2010. All rights reserved.
|
5
|
-
|
6
|
-
require 'rubygems'
|
7
|
-
require File.expand_path(File.dirname(__FILE__) + "/../lib/gren")
|
8
|
-
require "mkgrendb/cli"
|
9
|
-
|
10
|
-
Version = "0.2.4"
|
11
|
-
Mkgrendb::CLI.execute(STDOUT, ARGV)
|
data/lib/common/display_util.rb
DELETED
@@ -1,62 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
module Gren
|
4
|
-
module DisplayUtil
|
5
|
-
def time_s(time)
|
6
|
-
t = time.truncate
|
7
|
-
h = t / 3600
|
8
|
-
t = t % 3600
|
9
|
-
m = t / 60
|
10
|
-
t = t % 60
|
11
|
-
t += round(time - time.prec_i, 2)
|
12
|
-
|
13
|
-
if (h > 0 && m > 0)
|
14
|
-
"#{h}h #{m}m #{t}s"
|
15
|
-
elsif (m > 0)
|
16
|
-
"#{m}m #{t}s"
|
17
|
-
else
|
18
|
-
"#{t}sec"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
module_function :time_s
|
22
|
-
|
23
|
-
def round(n, d)
|
24
|
-
(n * 10 ** d).round / 10.0 ** d
|
25
|
-
end
|
26
|
-
module_function :round
|
27
|
-
|
28
|
-
def size_s(size)
|
29
|
-
tb = 1024 ** 4
|
30
|
-
gb = 1024 ** 3
|
31
|
-
mb = 1024 ** 2
|
32
|
-
kb = 1024
|
33
|
-
|
34
|
-
if (size >= tb)
|
35
|
-
round(size / tb.prec_f, 2).to_s + "TB"
|
36
|
-
elsif (size >= gb)
|
37
|
-
round(size / gb.prec_f, 2).to_s + "GB"
|
38
|
-
elsif (size >= mb)
|
39
|
-
round(size / mb.prec_f, 2).to_s + "MB"
|
40
|
-
elsif (size >= kb)
|
41
|
-
round(size / kb.prec_f, 2).to_s + "KB"
|
42
|
-
else
|
43
|
-
size.to_s + "Byte"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
module_function :size_s
|
47
|
-
|
48
|
-
def dump_methods(c)
|
49
|
-
unless c.is_a?(Class)
|
50
|
-
c = c.class
|
51
|
-
end
|
52
|
-
|
53
|
-
while (true)
|
54
|
-
p c
|
55
|
-
break if (c == Object)
|
56
|
-
puts "↓ " + c.public_instance_methods(false).inspect
|
57
|
-
c = c.superclass
|
58
|
-
end
|
59
|
-
end
|
60
|
-
module_function :dump_methods
|
61
|
-
end
|
62
|
-
end
|
data/lib/grendb/cli.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
require 'optparse'
|
3
|
-
require File.join(File.dirname(__FILE__), '../findgrep/findgrep')
|
4
|
-
|
5
|
-
module Grendb
|
6
|
-
class CLI
|
7
|
-
def self.execute(stdout, arguments=[])
|
8
|
-
# オプション
|
9
|
-
option = FindGrep::FindGrep::DEFAULT_OPTION
|
10
|
-
option.dbFile = ENV['GRENDB_DEFAULT_DB']
|
11
|
-
|
12
|
-
# デフォルトのマッチモードは'File'
|
13
|
-
option.isMatchFile = true
|
14
|
-
|
15
|
-
# オプション解析
|
16
|
-
opt = OptionParser.new("#{File.basename($0)} [option] keyword1 [keyword2 ...]")
|
17
|
-
opt.on('--db [GREN_DB_FILE]', 'Search from the grendb database.') {|v| option.dbFile = v }
|
18
|
-
opt.on('-f KEYWORD', '--file-keyword KEYWORD', 'Path keyword. (Enable multiple call)') {|v| option.filePatterns << v}
|
19
|
-
opt.on('-s SUFFIX', '--suffix SUFFIX', 'Search suffix.') {|v| option.suffixs << v }
|
20
|
-
opt.on('-i', '--ignore', 'Ignore case.') {|v| option.ignoreCase = true}
|
21
|
-
opt.on('-c', '--color', 'Color highlight.') {|v| option.colorHighlight = true}
|
22
|
-
opt.on('--no-snip', 'There being a long line, it does not snip.') {|v| option.noSnip = true }
|
23
|
-
opt.on('-g', '--groonga-only', 'Search only groonga db.') {|v| option.groongaOnly = true }
|
24
|
-
opt.on('--mf', '--match-file', 'Match file. (Default)') {|v| option.isMatchFile = true }
|
25
|
-
opt.on('-l', '--ml', '--match-line', 'Match line, same mode as "gren".') {|v| option.isMatchFile = false }
|
26
|
-
|
27
|
-
opt.parse!(arguments)
|
28
|
-
|
29
|
-
# 検索オブジェクトの生成
|
30
|
-
if (option.dbFile && (arguments.size > 0 || option.keywordsOr.size > 0))
|
31
|
-
findGrep = FindGrep::FindGrep.new(arguments, option)
|
32
|
-
findGrep.searchAndPrint(stdout)
|
33
|
-
else
|
34
|
-
stdout.print opt.help
|
35
|
-
stdout.puts
|
36
|
-
stdout.puts "please set GREN DATABSE FILE!! (--db option, or set ENV['GRENDB_DEFAULT_DB'].)" unless option.dbFile
|
37
|
-
end
|
38
|
-
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|