Class: Elm::Bin

Inherits:
Object
  • Object
show all
Includes:
Contracts::Builtin, Contracts::Core
Defined in:
lib/elm/bin.rb

Overview

Executable to be used in CLI

Class Method Summary collapse

Class Method Details

.exec(argv) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/elm/bin.rb', line 12

def self.exec(argv)
  options = Elm::OptParser.parse argv
  begin
    compile_output = Elm.compiler.files(argv, with_options: options).to_file
  rescue ExecutableNotFoundError => executable_not_found
    $stderr.puts executable_not_found.message
    exit false
  rescue CompilerError => compiler_error
    $stderr.puts compiler_error.message
    exit false
  end
  $stderr.puts compile_output.stderr
  puts compile_output.stdout
  true
end