Using the task dependency notation, you can pass in arguments to the default task. For example, say "version" is your argument:
task :default, [:version] => [:build]
task :build, :version do |t,args|
version = args[:version]
puts version ? "version is #{version}" : "no version passed"
end
Then you can call it like so:
$ rake
no version passed
or
$ rake default[3.2.1]
version is 3.2.1
or
$ rake build[3.2.1]
version is 3.2.1
However, I have not found a way to avoid specifying the task name (default or build) while passing in arguments.
Does anyone know of a way to use this notation and not have to specify the task name? (i.e. take advantage of the "default" syntax as well?)
I know of the ENV[] approach of receving parameters, as described here: How do I have the :default Rake task depend on a task with arguments?
I'm looking for a way to use the built in notation (as shown above) but avoid having to specify the task name.