Class: Sbuilder::Cli

Inherits:
Thor
  • Object
show all
Includes:
Utils::MyLogger
Defined in:
lib/cli/cli.rb

Constant Summary collapse

PROGNAME =

progname for logger default class name

nil
VERSION_BANNER =
<<-EOS.unindent
#{File.basename $0} - #{Sbuilder::version}   
EOS

Constants included from Utils::MyLogger

Utils::MyLogger::LOGFILE

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::MyLogger

#getLogger, #logfile

Constructor Details

#initialize(*args) ⇒ Cli


constructore



41
42
43
44
# File 'lib/cli/cli.rb', line 41

def initialize(*args)
  super
  @logger = getLogger( PROGNAME, options )
end

Class Method Details

.add_shared_option(name, options = {}) ⇒ Object



22
23
24
25
# File 'lib/cli/cli.rb', line 22

def add_shared_option(name, options = {})
  @shared_options = {} if @shared_options.nil?
  @shared_options[name] =  options
end

.shared_options(*option_names) ⇒ Object



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

def shared_options(*option_names)
  option_names.each do |option_name|
    opt =  @shared_options[option_name]
    raise "Tried to access shared option '#{option_name}' but it was not previously defined" if opt.nil?
    yield option_name, opt if block_given?
    option option_name, opt
  end
end

Instance Method Details

#document(what = nil) ⇒ Object



231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
# File 'lib/cli/cli.rb', line 231

def document( what=nil )
  controller = getCtrl
  controller.load
  
  validateWhats( what, getSetupNames(controller) ) if what
  
  invariants = controller.templateData('invariants')['invariants']
  puts "INVARIANTS:"
  invariants.each do |invariant|
    puts <<-EOS.unindent
      - #{invariant[:name]}: #{invariant[:desc]}
    EOS
  end
  setupsOutput=false
  controller.processSetups( what ) do |setupName, setupConf, possibilities|
    assumptions = controller.getSetupAssumptionList( setupConf )
    
    if !setupsOutput
      # Output SETUPS -header just before outputting first setup
      # configuration. This prevents any initialization output
      # from mixing between SETUPS header and setups data.
      setupsOutput =TRUE
      puts "SETUPS:"
    end
    
    puts <<-EOS.unindent 
    - #{setupName}: #{setupConf['desc']}
        - possibilities: #{(setupConf['possibilities'] || [] ).join( ' ' )}
        - assumptions: #{assumptions.join( ' ' )}
        - interfaces: #{controller.templateData('steps' )['steps'].map {|step| step[:interface_operation] }.uniq.join( ' ' )}
    EOS
  end
end

#extendObject



126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/cli/cli.rb', line 126

def extend()
  

  Dir.glob( File.join File.dirname( __FILE__), "../../src-extend/extend/extend_*.*" ).each do |extendTemplate|
    extend_files( "#{options[:src_dir]}/extend", extendTemplate, options[:benchmark] )
  end
  
  Dir.glob( File.join File.dirname( __FILE__), "../../src-extend/extend_app/*" ).each do |extendTemplate|
    extend_files( "#{options[:src_dir]}", extendTemplate )
  end
  
end

#generate(setupDirectory = nil) ⇒ Object



178
179
180
181
# File 'lib/cli/cli.rb', line 178

def generate( setupDirectory=nil)
  ctrl = getController( options )
  ctrl.setup( setupDirectory )
end

#initObject



155
156
157
158
159
160
161
# File 'lib/cli/cli.rb', line 155

def init()

  init_dirs( options )
  init_files( options )
  

end

#list(what) ⇒ Object



218
219
220
221
222
223
# File 'lib/cli/cli.rb', line 218

def list( what )
  validateWhats( what )                                        
  ctrl = getCtrl
  # puts "#{ctrl.getSetups().map { |setup| setup['setupDirectory']}.join(' ')}"
  puts "#{getSetupNames(ctrl).join(' ')}"      
end

#symbols(what = nil) ⇒ Object



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# File 'lib/cli/cli.rb', line 193

def symbols( what=nil )

  controller = getCtrl
  controller.load
  
  validateWhats( what, getSetupNames(controller) ) if what
  
  controller.processSetups( what ) do |setupName, setupConf, possibilities|
    st = controller.getSymbolTable
    puts <<-EOS.unindent 
        #{setupName}: #{setupConf['desc']}
        #{st.table.keys.map { |metatype| { metatype => st.getMetaTypeDescription(metatype), :maps=>st.table[metatype] } } .to_yaml}
    EOS
    
  end # processSetups
  

end

#versionObject



142
143
144
# File 'lib/cli/cli.rb', line 142

def version()
  puts VERSION_BANNER
end