Class: Antelope::CLI
- Inherits:
-
Thor
- Object
- Thor
- Antelope::CLI
- Defined in:
- lib/antelope/cli.rb
Overview
Handles the command line interface.
Instance Method Summary collapse
-
#check(*files) ⇒ Object
Check.
-
#compile(*files) ⇒ Object
Compile.
-
#compile_file(file, gen = :guess) ⇒ void
private
Compiles the given file, and then generates.
- #version ⇒ Object
Instance Method Details
#check(*files) ⇒ Object
Check.
26 27 28 29 30 |
# File 'lib/antelope/cli.rb', line 26 def check(*files) files.each do |file| compile_file(file, [Generator::Null]) end end |
#compile(*files) ⇒ Object
Compile.
17 18 19 20 21 |
# File 'lib/antelope/cli.rb', line 17 def compile(*files) files.each do |file| compile_file(file) end end |
#compile_file(file, gen = :guess) ⇒ void (private)
This method returns an undefined value.
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.
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/antelope/cli.rb', line 46 def compile_file(file, gen = :guess) puts "Compiling #{file}... " grammar = Grammar.from_file(file) grammar.generate(, gen) rescue => e $stderr.puts "Error while compiling: #{e.class}: #{e.message}" if [:verbose] $stderr.puts e.backtrace[0..10].map { |_| "\t#{_}" } end end |
#version ⇒ Object
33 34 35 |
# File 'lib/antelope/cli.rb', line 33 def version puts "Antelope version #{Antelope::VERSION}" end |