Permalink
Browse files

Always remove Testjour options from ARGV

  • Loading branch information...
1 parent ff40053 commit 3288881492e23b09594c3aa7b54cd1bd563e8c37 @brynary committed Oct 20, 2009
Showing with 17 additions and 18 deletions.
  1. +1 −1 bin/testjour
  2. +16 −17 lib/testjour/cli.rb
View
@@ -5,5 +5,5 @@ require "rubygems"
require File.expand_path(File.dirname(__FILE__) + "/../lib/testjour")
require "testjour/cli"
-result = Testjour::CLI.execute(ARGV.dup)
+result = Testjour::CLI.execute(ARGV)
Kernel.exit(result)
View
@@ -2,40 +2,39 @@
module Testjour
class CLI
-
+
def self.execute(*args)
new(*args).execute
end
-
+
def initialize(args, out_stream = STDOUT, err_stream = STDERR)
@args = args
@out_stream = out_stream
@err_stream = err_stream
end
-
- def command_class(args)
- if args.first == "--help"
- @args_for_command = @args[1..-1]
+
+ def command_class
+ case @args.first
+ when "--help"
+ @args.shift
Commands::Help
- elsif args.first == "--version"
- @args_for_command = @args[1..-1]
+ when "--version"
+ @args.shift
Commands::Version
- elsif args.first == "run:slave"
- @args_for_command = @args[1..-1]
+ when "run:slave"
+ @args.shift
Commands::RunSlave
- elsif args.first == "run:remote"
- @args_for_command = @args[1..-1]
+ when "run:remote"
+ @args.shift
Commands::RunRemote
else
- @args_for_command = @args.dup
Commands::Run
end
end
-
+
def execute
- klass = command_class(@args)
- klass.new(@args_for_command, @out_stream, @err_stream).execute || 0
+ command_class.new(@args, @out_stream, @err_stream).execute || 0
end
-
+
end
end

0 comments on commit 3288881

Please sign in to comment.