Sha256: 354a50b0aa167aad99793723b2a120f752a1c84ebceb17288cd90f73eb5de161

Contents?: true

Size: 1.99 KB

Versions: 5

Compression:

Stored size: 1.99 KB

Contents

#!/usr/bin/env ruby
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011  Kouhei Sutou <kou@clear-code.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1 as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

require 'ostruct'
require 'optparse'
require 'pathname'

require 'groonga'

options = OpenStruct.new
options.tables = []
options.dump_schema = true
options.dump_tables = true
option_parser = OptionParser.new do |parser|
  parser.banner += " DB_PATH"

  parser.on("--no-dump-schema",
            "don't dump schema.") do |boolean|
    options.dump_schema = boolean
  end

  parser.on("--no-dump-tables",
            "don't dump tables.") do |boolean|
    options.dump_tables = boolean
  end

  parser.on("-t=TABLE", "--table=TABLE",
            "dump only TABLE.",
            "use this option multiple to dump multiple tables.",
            "use /.../ as TABLE to match table name with regexp.") do |table|
    case table
    when /\A\/(.*)\/(i)?\z/
      options.tables << Regexp.new($1, $2 == "i")
    when
      options.tables << table
    end
  end
end
args = option_parser.parse!(ARGV)

if args.size != 1
  puts(option_parser)
  exit(false)
end
db_path = args[0]

database = Groonga::Database.open(db_path)
dumper_options = {
  :database => database,
  :output => STDOUT,
  :dump_schema => options.dump_schema,
  :dump_tables => options.dump_tables,
  :tables => options.tables,
}
database_dumper = Groonga::DatabaseDumper.new(dumper_options)
database_dumper.dump

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rroonga-1.2.4 bin/grndump
rroonga-1.2.3 bin/grndump
rroonga-1.2.2 bin/grndump
rroonga-1.2.1 bin/grndump
rroonga-1.2.0 bin/grndump