Sha256: 48e3268d263942343e598ebf92f2ca2b8989594c3366153092fdfaff0795ae83

Contents?: true

Size: 1.12 KB

Versions: 1

Compression:

Stored size: 1.12 KB

Contents

#!/usr/bin/env ruby

require 'optparse'

if File.directory?("#{File.dirname(__FILE__)}/../lib")
  $: << "#{File.dirname(__FILE__)}/../lib"
else
  require 'rubygems'
  gem 'protobuf'
end
require 'protobuf'
require 'protobuf/compiler/compiler'


options = {
  :proto_path => '.',
  :out => '.',
}
opts = OptionParser.new("#{$0} [OPTIONS] PROTO_FILE")
opts.on('-p', '--proto_path <PATH>', 'Specify the directory in which to search for imports. The current directory is default.'){|v| options[:proto_path] = v}
opts.on('-o', '--out <OUT_DIR>', 'Specify the directory in which Ruby source file is generated. The current directory is default.'){|v| options[:out] = v}
opts.on_tail('-v', '--version', 'Show version.'){ puts(opts.ver); exit }
opts.on_tail('-h', '--help', 'Show this message.'){ puts(opts.help); exit }

::Version = Protobuf::VERSION

begin
  opts.order!
rescue OptionParser::ParseError
  $stderr.puts $!.to_s
  exit 1
end

unless ARGV.size > 0
  puts opts
  exit
end

begin
  ARGV.each do |proto_file|
    Protobuf::Compiler.compile(proto_file, options[:proto_path], options[:out])
  end
rescue
  $stderr.puts $!.message
  exit 1
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
protobuf-1.0.0 bin/rprotoc