0

Ok, I have the following task,

namespace :test do
  task :a do |t,args|  
    p ENV.keys
  end 
end

$ rake test:a ARG1 = "me" ARG2 = "my wife"

The above command displays a big array i.e ENV.keys

ENV.keys looks like this,

["MANPATH", "SSH_AGENT_PID",........,"BUNDLE_BIN_PATH", "RUBYOPT", "ARG1", "ARG2"]

I want only "ARG1" and "ARG2" and I dont want "MANPATH","RUBYOPT" and other things. (Not "me" and "my wife").

The command line variable names. Not values.

Help?

beck03076
  • 3,268
  • 2
  • 27
  • 37

1 Answers1

0

Try it this way:

namespace :test do
  task :a, [:param_me, :param_wife] do |t, args|  
    p args.param_me
    p args.param_wife
  end 
end

$ rake "test:a[me, my wife]"

You will only need double quotes if you have spaces in your parameters.

Dave Sexton
  • 10,768
  • 3
  • 42
  • 56
  • I was not trying that way because, I have a comma in my parameters like, "me" "my wife" "my second, third and fourth wife". Note the comma in between second and third. That comma wont work with [this, way]. – beck03076 Apr 22 '13 at 18:56