[Rake-devel] Passing Command Line Values to a Rakefile?

Jim Weirich jim at weirichhouse.org
Sat Aug 20 18:27:53 EDT 2005

On Saturday 20 August 2005 02:49 am, Charles F. I. Savage wrote:
> However, I'd much rather be able to pass in the database name to the
> script.  Thus something like this from a shell script or other Ruby code:
> rake -f MyRakefile --options="database=test"
> rake -f MyRakefile --options="database=deploy"
> rake -f MyRakefile --options="database=production"

You can say: 
    rake -f MyRakefile DATABASE=production

The specified value will be placed in the ENV hash (e.g. ENV['DATABASE']).

-- Jim Weirich    jim at weirichhouse.org     http://onestepback.org
"Beware of bugs in the above code; I have only proved it correct, 
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)

More information about the Rake-devel mailing list