Class: Sbuilder::Cli
- Inherits:
-
Thor
- Object
- Thor
- Sbuilder::Cli
- Includes:
- Utils::MyLogger
- Defined in:
- lib/cli/cli.rb
Constant Summary collapse
- PROGNAME =
progname for logger default class name
nil- VERSION_BANNER =
"\#{File.basename $0} - \#{Sbuilder::version} \n".unindent
Constants included from Utils::MyLogger
Class Method Summary collapse
Instance Method Summary collapse
- #document(what = nil) ⇒ Object
- #extend ⇒ Object
- #generate(setupDirectory = nil) ⇒ Object
- #init ⇒ Object
-
#initialize(*args) ⇒ Cli
constructor
—————————————————————— constructore.
- #list(what) ⇒ Object
- #symbols(what = nil) ⇒ Object
- #version ⇒ Object
Methods included from Utils::MyLogger
Constructor Details
#initialize(*args) ⇒ Cli
constructore
41 42 43 44 |
# File 'lib/cli/cli.rb', line 41 def initialize(*args) super @logger = getLogger( PROGNAME, ) 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, = {}) = {} if .nil? [name] = end |
.shared_options(*option_names) ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/cli/cli.rb', line 27 def (*option_names) option_names.each do |option_name| opt = [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 " - \#{invariant[:name]}: \#{invariant[:desc]}\n EOS\n end\n setupsOutput=false\n controller.processSetups( what ) do |setupName, setupConf, possibilities|\n assumptions = controller.getSetupAssumptionList( setupConf )\n \n if !setupsOutput\n # Output SETUPS -header just before outputting first setup\n # configuration. This prevents any initialization output\n # from mixing between SETUPS header and setups data.\n setupsOutput =TRUE\n puts \"SETUPS:\"\n end\n \n puts <<-EOS.unindent \n - \#{setupName}: \#{setupConf['desc']}\n - possibilities: \#{(setupConf['possibilities'] || [] ).join( ' ' )}\n - assumptions: \#{assumptions.join( ' ' )}\n - interfaces: \#{controller.templateData('steps' )['steps'].map {|step| step[:interface_operation] }.uniq.join( ' ' )}\n EOS\n end\nend\n".unindent |
#extend ⇒ Object
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, [: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( ) ctrl.setup( setupDirectory ) end |
#init ⇒ Object
155 156 157 158 159 160 161 |
# File 'lib/cli/cli.rb', line 155 def init() init_dirs( ) init_files( ) 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 " \#{setupName}: \#{setupConf['desc']}\n \#{st.table.keys.map { |metatype| { metatype => st.getMetaTypeDescription(metatype), :maps=>st.table[metatype] } } .to_yaml}\n EOS\n \n end # processSetups\n \n\nend\n".unindent |
#version ⇒ Object
142 143 144 |
# File 'lib/cli/cli.rb', line 142 def version() puts VERSION_BANNER end |