Class: Baya::Binaries::Baya

Inherits:
Object
  • Object
show all
Defined in:
lib/baya/binaries/baya.rb

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Baya

Returns a new instance of Baya.



9
10
11
# File 'lib/baya/binaries/baya.rb', line 9

def initialize(args)
  @args = Configuration::CommandLine.new(args)
end

Instance Method Details

#errObject



43
44
45
# File 'lib/baya/binaries/baya.rb', line 43

def err
  STDERR
end

#outObject



39
40
41
# File 'lib/baya/binaries/baya.rb', line 39

def out
  STDOUT
end

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/baya/binaries/baya.rb', line 13

def run
  if @args.version
    out.puts "Baya v#{VERSION}"
    return
  end
  if @args.help
    out.puts @args.opts.help
    return
  end

  unless File.file?(@args.config)
    err.puts "Can't read configuration file '#{@args.config}'."
    err.puts "Make sure it exists and it is a file."
    return
  end

  @config = Configuration::File.new(@args.config)

  runner = Runner.new(@config)
  begin
    runner.run
  rescue => e
    err.puts "Error: #{e.message}"
  end
end