Class: Sbuilder::Cli

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

Constant Summary collapse

PROGNAME =

logger progname

"main"
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



197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
# File 'lib/cli/cli.rb', line 197

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
  puts "SETUPS:"      
  controller.processSetups( what ) do |setupName, setupConf, possibilities|
    assumptions = controller.getSetupAssumptionList( setupConf )
    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



121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/cli/cli.rb', line 121

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



175
176
177
178
# File 'lib/cli/cli.rb', line 175

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

#initObject



150
151
152
153
154
155
156
# File 'lib/cli/cli.rb', line 150

def init()

  init_dirs( options )
  init_files( options )
  

end

#list(what) ⇒ Object



186
187
188
189
190
191
# File 'lib/cli/cli.rb', line 186

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

#versionObject



137
138
139
# File 'lib/cli/cli.rb', line 137

def version()
  puts VERSION_BANNER
end