Sha256: d6dc4772675fede0942b201547f7744e2dae3ccf65ded23059bed36cc4584081

Contents?: true

Size: 732 Bytes

Versions: 7

Compression:

Stored size: 732 Bytes

Contents

# encoding: utf-8

require "thor"

module Antelope
  class CLI < Thor

    class_option :verbose, default: false, type: :boolean

    option :type, default: nil, type: :string,
      desc: "The type of generator to use"
    desc "compile FILE [FILE]*", "compile the given files"
    def compile(*files)
      files.each do |file|
        compile_file(file)
      end
    end

    private

    def compile_file(file)
      puts "Compiling #{file}... "

      grammar = Ace::Grammar.from_file(file)
      grammar.generate(options)

    rescue => e
      $stderr.puts "Error while compiling: #{e.class}: #{e.message}"

      if options[:verbose]
        $stderr.puts e.backtrace[0..10].map { |_| "\t#{_}" }
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
antelope-0.1.8 lib/antelope/cli.rb
antelope-0.1.7 lib/antelope/cli.rb
antelope-0.1.6 lib/antelope/cli.rb
antelope-0.1.5 lib/antelope/cli.rb
antelope-0.1.4 lib/antelope/cli.rb
antelope-0.1.3 lib/antelope/cli.rb
antelope-0.1.2 lib/antelope/cli.rb