[Groonga-commit] groonga/groonga-command-parser at c382458 [master] filter: add --no-include-schema and --no-include-load

アーカイブの一覧に戻る
Kouhei Sutou null+****@clear*****
Wed Mar 6 10:30:03 JST 2019


Kouhei Sutou	2019-03-06 10:30:03 +0900 (Wed, 06 Mar 2019)

  Revision: c38245840dd14b48c7d3b60c2d82b83b708bcea2
  https://github.com/groonga/groonga-command-parser/commit/c38245840dd14b48c7d3b60c2d82b83b708bcea2

  Message:
    filter: add --no-include-schema and --no-include-load

  Modified files:
    lib/groonga/command/parser/command/groonga-command-filter.rb

  Modified: lib/groonga/command/parser/command/groonga-command-filter.rb (+17 -0)
===================================================================
--- lib/groonga/command/parser/command/groonga-command-filter.rb    2019-03-06 10:28:02 +0900 (4c64fd6)
+++ lib/groonga/command/parser/command/groonga-command-filter.rb    2019-03-06 10:30:03 +0900 (e46f86d)
@@ -25,6 +25,8 @@ module Groonga
         class GroongaCommandFilter
           def initialize
             @include_tables = {}
+            @include_schema = true
+            @include_load = true
           end
 
           def run(argv=ARGV)
@@ -64,6 +66,16 @@ module Groonga
               @include_tables[table][column] = true
             end
 
+            option_parser.on("--no-include-schema",
+                             "Remove schema manipulation commands") do |boolean|
+              @include_schema = boolean
+            end
+
+            option_parser.on("--no-include-load",
+                             "Remove load command") do |boolean|
+              @include_load = boolean
+            end
+
             option_parser.parse!(argv)
           end
 
@@ -95,6 +107,7 @@ module Groonga
 
           private
           def filter_command(command)
+            return unless @include_schema # TODO: Too loose
             case command
             when TableCreate
               return unless target_table?(command.name)
@@ -108,6 +121,7 @@ module Groonga
           end
 
           def filter_load_start(command)
+            return unless @include_load
             return unless target_table?(command.table)
             puts(command)
             puts("[")
@@ -115,6 +129,7 @@ module Groonga
           end
 
           def filter_load_columns(command, columns)
+            return unless @include_load
             columns = extract_target_columns(command.table, columns)
             return unless columns
             print(JSON.generate(columns))
@@ -122,6 +137,7 @@ module Groonga
           end
 
           def filter_load_value(command, value)
+            return unless @include_load
             return unless target_table?(command.table)
             value = extract_target_attributes(command.table,
                                               command.columns,
@@ -133,6 +149,7 @@ module Groonga
           end
 
           def filter_load_complete(command)
+            return unless @include_load
             return unless target_table?(command.table)
             puts(",") if @need_comma
             puts("]")
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.osdn.me/mailman/archives/groonga-commit/attachments/20190306/9956decc/attachment-0001.html>


More information about the Groonga-commit mailing list
アーカイブの一覧に戻る