class Antelope::CLI
Handles the command line interface.
Public Instance Methods
check(*files)
click to toggle source
Check.
# File lib/antelope/cli.rb, line 26 def check(*files) files.each do |file| compile_file(file, [Generator::Null]) end end
compile(*files)
click to toggle source
Compile.
# File lib/antelope/cli.rb, line 17 def compile(*files) files.each do |file| compile_file(file) end end
version()
click to toggle source
# File lib/antelope/cli.rb, line 33 def version puts "Antelope version #{Antelope::VERSION}" end
Private Instance Methods
compile_file(file, gen = :guess)
click to toggle source
Compiles the given file, and then generates. If an error occurs, it prints it out to stderr, along with a backtrace if the verbose flag was set.
@param file [String] the file to compile. @param gen [Array, Symbol] the generator to use. @return [void]
# File lib/antelope/cli.rb, line 46 def compile_file(file, gen = :guess) puts "Compiling #{file}... " grammar = Grammar.from_file(file) grammar.generate(options, gen) rescue => e $stderr.puts "Error while compiling: #{e.class}: #{e.message}" if options[:verbose] $stderr.puts e.backtrace[0..10].map { |_| "\t#{_}" } end end