Skip to content

Commit

Permalink
Always remove Testjour options from ARGV
Browse files Browse the repository at this point in the history
  • Loading branch information
brynary committed Oct 20, 2009
1 parent ff40053 commit 3288881
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bin/testjour
Original file line number Diff line number Diff line change
Expand Up @@ -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)
33 changes: 16 additions & 17 deletions lib/testjour/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.