Sha256: 926826791b26ce77453d53a80351121735743260e1838236d0a0790a527b843a
Contents?: true
Size: 1.81 KB
Versions: 4
Compression:
Stored size: 1.81 KB
Contents
# -*- coding: utf-8 -*- require 'optparse' require File.join(File.dirname(__FILE__), '../findgrep/findgrep') module Grendb class CLI def self.execute(stdout, arguments=[]) # オプション option = FindGrep::FindGrep::DEFAULT_OPTION option.dbFile = ENV['GRENDB_DEFAULT_DB'] # デフォルトのマッチモードは'File' option.isMatchFile = true # オプション解析 opt = OptionParser.new("#{File.basename($0)} [option] keyword1 [keyword2 ...]") opt.on('--db [GREN_DB_FILE]', 'Search from the grendb database.') {|v| option.dbFile = v } opt.on('-f KEYWORD', '--file-keyword KEYWORD', 'Path keyword. (Enable multiple call)') {|v| option.filePatterns << v} opt.on('-s SUFFIX', '--suffix SUFFIX', 'Search suffix.') {|v| option.suffixs << v } opt.on('-i', '--ignore', 'Ignore case.') {|v| option.ignoreCase = true} opt.on('-c', '--color', 'Color highlight.') {|v| option.colorHighlight = true} opt.on('--no-snip', 'There being a long line, it does not snip.') {|v| option.noSnip = true } opt.on('-g', '--groonga-only', 'Search only groonga db.') {|v| option.groongaOnly = true } opt.on('--mf', '--match-file', 'Match file. (Default)') {|v| option.isMatchFile = true } opt.on('-l', '--ml', '--match-line', 'Match line, same mode as "gren".') {|v| option.isMatchFile = false } opt.parse!(arguments) # 検索オブジェクトの生成 if (option.dbFile && (arguments.size > 0 || option.keywordsOr.size > 0)) findGrep = FindGrep::FindGrep.new(arguments, option) findGrep.searchAndPrint(stdout) else stdout.print opt.help stdout.puts stdout.puts "please set GREN DATABSE FILE!! (--db option, or set ENV['GRENDB_DEFAULT_DB'].)" unless option.dbFile end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
gren-0.3.2 | lib/grendb/cli.rb |
gren-0.3.1 | lib/grendb/cli.rb |
gren-0.3.0 | lib/grendb/cli.rb |
gren-0.2.4 | lib/grendb/cli.rb |