[Groonga-commit] groonga/gcs [master] Add new command line tool cs-configure-fields

Back to archive index

null+****@clear***** null+****@clear*****
2012年 8月 3日 (金) 18:48:06 JST


SHIMODA Hiroshi	2012-08-03 18:48:06 +0900 (Fri, 03 Aug 2012)

  New Revision: 82d56047e7a31e3cf90fe8315f1ba7a18beee415
  https://github.com/groonga/gcs/commit/82d56047e7a31e3cf90fe8315f1ba7a18beee415

  Log:
    Add new command line tool cs-configure-fields

  Added files:
    bin/cs-configure-fields
  Modified files:
    bin/cs-create-domain
    bin/cs-describe-domain

  Added: bin/cs-configure-fields (+54 -0) 100755
===================================================================
--- /dev/null
+++ bin/cs-configure-fields    2012-08-03 18:48:06 +0900 (30642ca)
@@ -0,0 +1,54 @@
+#!/usr/bin/env node
+
+var program = require('commander');
+var commandLine = require(__dirname + '/../lib/command-line');
+
+program
+  .version(require('../package').version)
+  .usage('--name <field name> --type <field type> [options]')
+  .option('--name <field name>',
+          'The name of the field you are configuring or deleting. Required.',
+          String)
+  .option('--type <field type>',
+          'The type of the field that you are configuring or deleting: ' +
+            'text, literal, uint. Required.',
+          String)
+  .option('-d, --type <field type>',
+          'The name of the domain that you are configuring. Required.',
+          String)
+  .option('--delete',
+          'Delete the field specified by the --name and --type options.')
+  .option('--database-path <path>',
+          'database path [' + commandLine.defaultDatabasePath + ']',
+          String,
+          commandLine.defaultDatabasePath)
+  .parse(process.argv);
+
+if (!program.domainName) {
+  console.log('You must specify the domain name.');
+  return false;
+}
+
+var context = commandLine.getContext(program.databasePath);
+var domain = new commandLine.Domain(program.domainName, context);
+if (!domain.exists()) {
+  console.log('You must specify an existing domain name.');
+  return false;
+}
+
+if (!program.name) {
+  console.log('You must specify the field name.');
+  return false;
+}
+if (!program.type) {
+  console.log('You must specify the field type.');
+  return false;
+}
+
+var field = domain.getIndexField(program.name);
+field.type = program.type;
+
+field.createSync();
+
+console.log('Updated 1 Index Field:');
+console.log(field.name + ' ' + field.state + ' ' + field.type + '()');

  Modified: bin/cs-create-domain (+2 -2)
===================================================================
--- bin/cs-create-domain    2012-08-03 18:17:00 +0900 (0a0c9d6)
+++ bin/cs-create-domain    2012-08-03 18:48:06 +0900 (9088a6d)
@@ -5,9 +5,9 @@ var commandLine = require(__dirname + '/../lib/command-line');
 
 program
   .version(require('../package').version)
-  .usage('[options] --domain-name <domain name>')
+  .usage('--domain-name <domain name> [options]')
   .option('-d, --domain-name <domain name>',
-          'name for the new domain',
+          'The name of the domain that you are creating. Required.',
           String)
   .option('--database-path <path>',
           'database path [' + commandLine.defaultDatabasePath + ']',

  Modified: bin/cs-describe-domain (+3 -2)
===================================================================
--- bin/cs-describe-domain    2012-08-03 18:17:00 +0900 (2233956)
+++ bin/cs-describe-domain    2012-08-03 18:48:06 +0900 (13ccd93)
@@ -7,10 +7,11 @@ program
   .version(require('../package').version)
   .usage('[options]')
   .option('-d, --domain-name <domain name>',
-          'name for the new domain',
+          'The name of the domain that you are creating. Required.',
           String)
   .option('-all, --show-all',
-          'name for the new domain',
+          'Display all available information for the domain, '
+             'including configured fields.',
           String)
   .option('--database-path <path>',
           'database path [' + commandLine.defaultDatabasePath + ']',
-------------- next part --------------
HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...
다운로드 



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