rake
rake copied to clipboard
load Rakefile before executing `-p`, `-e`, and `-E` code
Let's say we have this sad little Rakefile:
FOO=23*42
And we want to find out the value of FOO. We look at the --help output, and -p sounds promising:
$ rake --help
...
-p, --execute-print CODE Execute some Ruby code, print the result, then exit.
...
But when we try it...
$ rake -p 'FOO'
rake aborted!
NameError: uninitialized constant Rake::Application::FOO
(See full trace by running task with --trace)
...this is confusing! Especially for a Rake novice.
We can get the result we intended:
$ rake -p 'load_rakefile; FOO'
966
But this requires substantial inner knowledge of Rake.
Suggested behavior:
$ rake -p 'FOO'
966
Thoughts, anyone? Is there a reason I'm missing that -e, -E, and -p don't load the rakefile by default?