Class: Bake::ConfigNames

Inherits:
Object
  • Object
show all
Defined in:
lib/bake/options/showConfigNames.rb

Class Method Summary collapse

Class Method Details



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bake/options/showConfigNames.rb', line 8

def self.print(configs, default, filename)
  foundValidConfig = false
  configs.each do |c|
    next if c.defaultToolchain.nil?
    foundValidConfig = true
    Kernel.print "* #{c.name}"
    Kernel.print " (default)" if c.name ==  default
    Kernel.print ": #{c.description.text}" if c.description
    Kernel.print "\n"
  end
  Bake.formatter.printWarning("No configuration with a DefaultToolchain found", filename) unless foundValidConfig
  
  ExitHelper.exit(0)
end

.showObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/bake/options/showConfigNames.rb', line 23

def self.show
  loader = Loader.new
  filename = Bake.options.main_dir+"/Project.meta"
  f = loader.load(filename)
  
  if f.root_elements.length != 1 or not Metamodel::Project === f.root_elements[0]
    Bake.formatter.printError("Config file must have exactly one 'Project' element as root element", filename)
    ExitHelper.exit(1)
  end
  
  default = f.root_elements[0].default
  configs = f.root_elements[0].getConfig
 
  ConfigNames.print(configs, default, filename)
end