Class: Groonga::Client::CommandLine::GroongaClient
- Inherits:
-
Object
- Object
- Groonga::Client::CommandLine::GroongaClient
- Defined in:
- lib/groonga/client/command-line/groonga-client.rb
Defined Under Namespace
Classes: BareREPL, ReadlineREPL, Runner
Instance Method Summary collapse
-
#initialize ⇒ GroongaClient
constructor
A new instance of GroongaClient.
- #run(arguments) ⇒ Object
Constructor Details
#initialize ⇒ GroongaClient
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/groonga/client/command-line/groonga-client.rb', line 36 def initialize @chunk = false @load_input_type = "json" @available_load_input_types = ["json"] if Object.const_defined?(:Arrow) @available_load_input_types << "apache-arrow" end @load_lock_table = false = { :split_load_chunk_size => 10000, :generate_request_id => false, :target_commands => [], :target_tables => [], :target_columns => [], } end |
Instance Method Details
#run(arguments) ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/groonga/client/command-line/groonga-client.rb', line 54 def run(arguments) parser = Parser.new command_file_paths = parser.parse(arguments) do |option_parser| parse_command_line(option_parser) end parser.open_client(:chunk => @chunk, :load_input_type => @load_input_type, :load_lock_table => @load_lock_table) do |client| runner = Runner.new(client, ) if command_file_paths.empty? if $stdin.tty? and $stdout.tty? begin require "readline" rescue LoadError repl = BareREPL.new(runner) else repl = ReadlineREPL.new(runner) end repl.run else $stdin.each_line do |line| runner << line end end else command_file_paths.each do |command_file_path| File.open(command_file_path) do |command_file| last_line = nil command_file.each_line do |line| last_line = line runner << line end if last_line and !last_line.end_with?("\n") runner << "\n" end end end end runner.finish end true end |