Method: Lolcode::CLI#initialize

Defined in:
lib/lolcode/cli.rb

#initializeCLI

Returns a new instance of CLI.



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/lolcode/cli.rb', line 8

def initialize
  self.options = {}

  OptionParser.new do |opts|
    opts.banner =
"Welcome to Lolcode.\nWhen file is given it is a script excutor, otherwise it's a interpretor.\nUsage: lolcode [options] [file]\n"

    opts.on("-v", "Run verbosely") do |v|
      self.options[:verbose] = v
    end

    opts.on_tail("-h", "--help", "Show this message") do
      puts opts
      exit 1
    end

    self.files = opts.permute(ARGV) # rest args in ARGV
  end.parse!

  if self.files.empty?
    interpretor
  else
    excutor
  end
end