[Groonga-commit] groonga/groonga [command-version] add --default-command-version option.

Back to archive index

null+****@clear***** null+****@clear*****
2010年 9月 14日 (火) 12:12:42 JST


Kouhei Sutou	2010-09-14 03:12:42 +0000 (Tue, 14 Sep 2010)

  New Revision: e0e869297f948d7d96d26863100e71d78bcfd2af

  Log:
    add --default-command-version option.

  Modified files:
    src/groonga.c
    test/unit/command/test-option.rb

  Modified: src/groonga.c (+8 -1)
===================================================================
--- src/groonga.c    2010-09-14 02:50:02 +0000 (ec0f7b9)
+++ src/groonga.c    2010-09-14 03:12:42 +0000 (9f6c5e7)
@@ -106,6 +106,8 @@ usage(FILE *output)
           "  --config-path <path>:             specify config file path\n"
           "  --cache-limit <limit>:            specify the max number of cache data\n"
           "  --file <path>:                    read commands from specified file\n"
+          "  --default-command-version <version>:\n"
+          "                                    specify default command version\n"
           "\n"
           "dest: <db pathname> [<command>] or <dest hostname>\n"
           "  <db pathname> [<command>]: when standalone/server mode\n"
@@ -2063,7 +2065,7 @@ main(int argc, char **argv)
   const char *portstr = NULL, *encstr = NULL,
     *max_nfthreadsstr = NULL, *loglevel = NULL,
     *listen_addressstr = NULL, *hostnamestr = NULL, *protocol = NULL,
-    *cache_limitstr = NULL, *admin_html_path = NULL;
+    *cache_limitstr = NULL, *admin_html_path = NULL, *command_versionstr = NULL;
   const char *config_path = NULL;
   const char *input_path = NULL;
   int r, i, mode = mode_alone;
@@ -2091,6 +2093,7 @@ main(int argc, char **argv)
     {'\0', "cache-limit", NULL, 0, getopt_op_none},
     {'\0', "file", NULL, 0, getopt_op_none},
     {'\0', "document-root", NULL, 0, getopt_op_none},
+    {'\0', "default-command-version", NULL, 0, getopt_op_none},
     {'\0', NULL, NULL, 0, 0}
   };
   opts[0].arg = &portstr;
@@ -2108,6 +2111,7 @@ main(int argc, char **argv)
   opts[20].arg = &cache_limitstr;
   opts[21].arg = &input_path;
   opts[22].arg = &grn_document_root;
+  opts[23].arg = &command_versionstr;
   if (!(default_max_nfthreads = get_core_number())) {
     default_max_nfthreads = DEFAULT_MAX_NFTHREADS;
   }
@@ -2244,6 +2248,9 @@ main(int argc, char **argv)
 #endif
   if (grn_init()) { return -1; }
   grn_set_default_encoding(enc);
+  if (command_versionstr) {
+    grn_set_default_command_version(atoi(command_versionstr));
+  }
   if (loglevel) { SET_LOGLEVEL(atoi(loglevel)); }
   grn_set_segv_handler();
   grn_set_int_handler();

  Modified: test/unit/command/test-option.rb (+7 -0)
===================================================================
--- test/unit/command/test-option.rb    2010-09-14 02:50:02 +0000 (b6a092e)
+++ test/unit/command/test-option.rb    2010-09-14 03:12:42 +0000 (863a3f2)
@@ -103,4 +103,11 @@ class OptionTest < Test::Unit::TestCase
   ensure
     FileUtils.rm_f(config_file)
   end
+
+  def test_default_command_version
+    result = JSON.parse(run_groonga("--default-command-version", "1",
+                                    "-n", @database_path,
+                                    "status"))
+    assert_equal(1, result[1]["command_version"])
+  end
 end




Groonga-commit メーリングリストの案内
Back to archive index