Class: KaiserRuby::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/kaiser_ruby/cli.rb

Instance Method Summary collapse

Instance Method Details

#execute(filename) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/kaiser_ruby/cli.rb', line 29

def execute(filename)
  file = File.read filename
  output = KaiserRuby.transpile(file)

  eval output
  puts
end

#transpile(filename) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/kaiser_ruby/cli.rb', line 8

def transpile(filename)
  file = File.read filename
  output = KaiserRuby.transpile(file)

  if options['show-source'.to_sym]
    puts file
    puts "-" * 40
  end

  if options[:save]
    out = File.new(options[:save], 'w')
    out.write output
    out.close
    puts "Saved output in `#{options[:save]}`"
  else
    puts output
  end
  puts
end