Class: BuildTool::Commands::Standard
- Defined in:
- lib/build-tool/commands.rb
Direct Known Subclasses
Configuration::Edit, Configuration::List, Environments::List, Environments::Set, Features::Disable, Features::Enable, Features::List, Files, History, Info, ModuleBasedCommand, Modules::List, Recipes::Add, Recipes::Edit, Recipes::Incoming, Recipes::Info, Recipes::Install, Recipes::List
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #complete_module(name, include_templates = false) ⇒ Object
-
#complete_modules(name, include_templates = false) ⇒ Object
Gathers all modules currently known.
-
#initialize(*args) ⇒ Standard
constructor
A new instance of Standard.
- #initialize_options ⇒ Object
-
#log_directory ⇒ Object
On demand initialization.
- #while_logging_to(dir, fname, level, &block) ⇒ Object
Methods inherited from Base
#<=>, #applicable?, #cleanup_after_vcs_access, #complete_arguments, #complete_readline, #configuration, #debug, #debug2, #do_complete, #do_execute, #each_option, #error, #execute, #fullname, #info, #log?, #quiet, #setup_command, #setup_options, #show_help, #skip_command, #summarize, #teardown_command, #trace, #usage, #verbose, #warn
Methods included from HelpText
#cmdalias, #description, included, #long_description, #name
Constructor Details
#initialize(*args) ⇒ Standard
Returns a new instance of Standard.
360 361 362 363 364 |
# File 'lib/build-tool/commands.rb', line 360 def initialize( *args ) # Only used by child classes but needed for complete_modules @all = false super( *args ) end |
Instance Method Details
#complete_module(name, include_templates = false) ⇒ Object
394 395 396 |
# File 'lib/build-tool/commands.rb', line 394 def complete_module( name, include_templates = false ) configuration.complete_module( name, include_templates, @all, @resume_from, @resume_after ) end |
#complete_modules(name, include_templates = false) ⇒ Object
Gathers all modules currently known.
390 391 392 |
# File 'lib/build-tool/commands.rb', line 390 def complete_modules( name, include_templates = false ) configuration.complete_modules( name, include_templates, @all, @resume_from, @resume_after ) end |
#initialize_options ⇒ Object
366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/build-tool/commands.rb', line 366 def .separator '' .separator "Common options" .on( "-v", "--verbose", "Enable verbose output" ) do Logging.appenders['stdout'].level = [ Logging.appenders['stdout'].level - 1, 0 ].max() end .on( "-q", "--quiet", "More quiet output" ) do Logging.appenders['stdout'].level = [ Logging.appenders['stdout'].level + 1, 0 ].max() end .on( nil, "--dry-run", "Enable dry run." ) do $noop = true end .on( "-h", "--help", "Show this help text" ) do show_help end end |
#log_directory ⇒ Object
On demand initialization
432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
# File 'lib/build-tool/commands.rb', line 432 def log_directory return @log_directory if @log_directory # Get the root logfile directory logdir = configuration.log_directory # Try to find the next log directory for today. i = -1 begin @log_directory = logdir.join( "#{Date.today.to_s}-%02d" % i+=1 ) end until !@log_directory.exist? # If noop is active we are finished return @log_directory if $noop # Ensure the base log directory exists. if !File.exist? "#{logdir}" FileUtils.mkdir_p "#{logdir}" end # Create the latest symbolic link FileUtils.mkdir_p( @log_directory.to_s ) FileUtils.rm_f( "#{logdir}/latest" ) FileUtils.ln_sf( @log_directory.to_s, "#{logdir}/latest" ) @log_directory end |
#while_logging_to(dir, fname, level, &block) ⇒ Object
398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 |
# File 'lib/build-tool/commands.rb', line 398 def while_logging_to( dir, fname, level, &block ) got_exception = false # Only create a logfile if we do real work if log? dirname = log_directory dirname += dir if dir FileUtils.mkdir_p( dirname ) Logging.logger['root'].add_appenders( Logging.appenders.file( fname, :filename => dirname + fname, :layout => Logging::Layouts::Pattern.new( :pattern => '%m\n' ), :level => level )) end begin yield rescue Interrupt => e error( "User Interrupt!" ) rescue BuildTool::Error => e error( "#{e.}" ) got_exception = true raise e rescue Exception => e error( "#{e.class}:#{e.}" ) got_exception = true raise e ensure Logging.logger['root'].remove_appenders( fname ) info( "More information in #{dirname}/#{fname}" ) if got_exception end end |