From 39bc832fea040b2321aed6afa5b74a7c42643001 Mon Sep 17 00:00:00 2001 From: Alan Johnson Date: Mon, 23 Jan 2012 20:49:50 -0500 Subject: [PATCH] Added support for --trace argument to help out with troubleshooting. --- bin/tconsole | 2 +- lib/tconsole.rb | 8 ++++++-- lib/tconsole/server.rb | 14 ++++++++++++-- lib/tconsole/version.rb | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/bin/tconsole b/bin/tconsole index 746ebcf..fb3a09f 100755 --- a/bin/tconsole +++ b/bin/tconsole @@ -2,4 +2,4 @@ require File.join(File.dirname(__FILE__), "..", "lib", "tconsole") -TConsole::Runner.run +TConsole::Runner.run(ARGV) diff --git a/lib/tconsole.rb b/lib/tconsole.rb index 9f85e41..f691550 100644 --- a/lib/tconsole.rb +++ b/lib/tconsole.rb @@ -11,7 +11,7 @@ class Runner SERVER_URI = "druby://localhost:8788" # Spawns a new environment. Looks at the results of the environment to determine whether to stop or # keep running - def self.run + def self.run(argv) stty_save = `stty -g`.chomp running = true @@ -24,13 +24,17 @@ def self.run # Set up our console input handling and history console = Console.new + # set up the config + config = {:trace => false} + config[:trace] = true if argv.include?("--trace") + # Start the server while running # ignore ctrl-c during load, since things can get kind of messy if we don't fork do begin - server = Server.new + server = Server.new(config) DRb.start_service(SERVER_URI, server) diff --git a/lib/tconsole/server.rb b/lib/tconsole/server.rb index 723e0ca..885680e 100644 --- a/lib/tconsole/server.rb +++ b/lib/tconsole/server.rb @@ -1,5 +1,11 @@ module TConsole class Server + attr_accessor :config + + def initialize(config) + self.config = config + end + def stop DRb.stop_service end @@ -19,8 +25,12 @@ def load_environment Rake.application.invoke_task("db:test:load") Rake.application.invoke_task("test:prepare") rescue Exception => e - puts "Error: Loading your environment failed." - puts " #{e.message}" + puts "Error - Loading your environment failed: #{e.message}" + if config[:trace] == true + puts + puts " #{e.backtrace.join("\n ")}" + end + return false end end diff --git a/lib/tconsole/version.rb b/lib/tconsole/version.rb index 32a83b3..d504ad7 100644 --- a/lib/tconsole/version.rb +++ b/lib/tconsole/version.rb @@ -1,3 +1,3 @@ module TConsole - VERSION = "1.0.0" + VERSION = "1.0.1pre1" end