Sha256: c4dda281d965f55e756802c5ec09b59342321d3761ee2b6c40b127e297ad0a6f
Contents?: true
Size: 1.88 KB
Versions: 3
Compression:
Stored size: 1.88 KB
Contents
require 'getoptlong' module FFI module Generator class Application OPTIONS = [ [ "--help", "-u", GetoptLong::NO_ARGUMENT, "Display help information." ], [ "--version", "-v", GetoptLong::NO_ARGUMENT, "Display the version number and quit." ], ] USAGE_PREAMBLE = <<-EOU Usage: ffi-gen [options] <input_file> <output_file> <input_file> is the xml parse tree generated by swig -xml command. <output_file> is the ruby-ffi wrapper file. EOU class << self def run process_args if ARGV.size == 2 File.open(ARGV[1], 'w') do |file| file << FFI::Generator::Parser.generate(Nokogiri::XML(File.open(ARGV[0]))) end else help raise "Invalid number of arguments!" end end private def do_option(option, value = nil) case option when '--help' help exit when '--version' puts "ffi-generator, version #{Generator::VERSION}\n" exit end end def command_line_options OPTIONS.collect { |lst| lst[0..-2] } end def process_args opts = GetoptLong.new(*command_line_options) opts.each { |opt, value| do_option(opt, value) } end def help puts puts USAGE_PREAMBLE puts "Recognized options are:" puts OPTIONS.sort.each do |long, short, mode, desc| if mode == GetoptLong::REQUIRED_ARGUMENT if desc =~ /\b([A-Z]{2,})\b/ long = long + "=#{$1}" end end printf " %-20s (%s)\n", long, short printf " %s\n", desc puts end end end end end end
Version data entries
3 entries across 3 versions & 2 rubygems
Version | Path |
---|---|
remogatto-ffi-generator-0.1.0 | lib/generator/application.rb |
remogatto-ffi-generator-0.2.0 | lib/generator/application.rb |
remogatto-ffi-swig-generator-0.2.0 | lib/generator/application.rb |