Sha256: 2e7e4eb7146fab384db160b0b53d89c1b6d65880e5d418cf0928484a22c45582
Contents?: true
Size: 1.91 KB
Versions: 1
Compression:
Stored size: 1.91 KB
Contents
# -*- coding: utf-8 -*- require 'optparse' require File.join(File.dirname(__FILE__), '../findgrep/findgrep') require File.join(File.dirname(__FILE__), '../common/dbdir') include CodeStock module Grendb class CLI def self.execute(stdout, arguments=[]) # オプション option = FindGrep::FindGrep::DEFAULT_OPTION option.dbFile = db_groonga_path(db_default_dir) # デフォルトのマッチモードは'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 = db_groonga_path(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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
codestock-0.1.0 | lib/grendb/cli.rb |