Sha256: e8e9f0d544ea7558d80e39f1116eade98a1ffcde7a5e4b33b28c376694bff2b3

Contents?: true

Size: 779 Bytes

Versions: 1

Compression:

Stored size: 779 Bytes

Contents

require 'slop'

module Xdrgen
  module CLI
    def self.run(args)
      args = args.dup
      opts = Slop.parse! args do
        banner 'Usage: xdrgen -o OUTPUT_DIR INPUT --language=ruby'
        on 'o', 'output=', 'The output directory'
        on 'l', 'language=', 'The output language', default: 'ruby'
        on 'n', 'namespace=', '"namespace" to generate code within (language-specific)'
      end

      fail(opts) if args.blank?
      fail(opts) if opts[:output].blank?

      compilation = Compilation.new(
        args,
        output_dir: opts[:output],
        language:   opts[:language].to_sym,
        namespace:  opts[:namespace]
      )
      compilation.compile
    end

    def self.fail(slop, code=1)
      STDERR.puts slop
      exit(code)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
xdrgen-0.1.1 lib/xdrgen/cli.rb