bin/tl in testlab-0.9.0 vs bin/tl in testlab-0.9.1

- old
+ new

@@ -59,10 +59,12 @@ arg_name 'path/to/directory' # default_value File.join(Dir.pwd, ".testlab-#{TestLab.hostname}") flag [:c, :config] pre do |global,command,options,args| + @testlab_start_time = Time.now.utc + (global[:verbose] == true) and (ENV['LOG_LEVEL'] = 'DEBUG') log_file = File.join(global[:repo], "testlab-#{TestLab.hostname}.log") @logger = ZTK::Logger.new(log_file) @@ -95,18 +97,24 @@ true end post do |global,command,options,args| - # Post logic here - # Use skips_post before a command to skip this - # block on that command only + testlab_run_time = (Time.now.utc - @testlab_start_time) + + message = format_message("TestLab v#{TestLab::VERSION} Finished (%0.4f seconds)".black.bold % testlab_run_time) + @testlab.ui.stdout.puts(message) + @testlab.ui.logger.info { message } + + true end on_error do |exception| + testlab_run_time = (Time.now.utc - @testlab_start_time) + @ui.stderr.puts - @ui.stderr.puts(format_message(["ERROR:".red, exception.message.red.bold].join(' '))) + @ui.stderr.puts(format_message(["ERROR:".red, exception.inspect.red.bold].join(' '))) case exception when GLI::BadCommandLine, GLI::UnknownCommand, GLI::UnknownCommandArgument, GLI::UnknownGlobalArgument then command_regex = /Command '([\w]+)' / command = exception.message.scan(command_regex).flatten.first @@ -118,9 +126,13 @@ else @logger.fatal { exception.inspect } exception.backtrace.each do |line| @logger.logdev.write("#{line}\n") end + + message = format_message("TestLab v#{TestLab::VERSION} Aborted (%0.4f seconds)".black.bold % testlab_run_time) + @testlab.ui.stderr.puts(message) + @testlab.ui.logger.info { message } false end end